From the course: Build Modern Web Apps with React, Hooks, State Management, and APIs Using Vite or Next.js

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

useReducer status manager example

useReducer status manager example

Hello and welcome back. Let's quickly start off with our useReducer detail example. So in the components folder, we are going to have a component being defined for the useReducer example and we are going to call it statusManager.tsx. We are going to do the status example in that case. I'm going to call rafce. That is going to give me my component. After that, I'm going to define a few types here. I'm going to explain it at the end. So we are going to have our first type for status. This will define what values of the status we can have. So it can be pending, it can be in progress, in review and lastly we can have completed. And let's also define a type for our action. We can have an action of type start and we can have an action of type review. one will be complete and the last action we can expect is type reset. So these are all the type of actions that can be performed on our status state. Now let's write down our reducer function. So we are going to do a status reducer, that…

Contents