growthmindsit

Advanced State with Reducers

Review, Research, and Discussion

Document the following Vocabulary Terms

Preparation Materials

useReducer

useReducer() is a method from the React Hooks API, similar to useState but gives you more control to manage the state. It takes a reducer function and initial state as arguments and returns the state and dispatch method

3 Reasons to Use It

  1. Next state depends on the previous.
  2. Complex state shape
  3. Easy to test

useReducer() is an alternative to useState() which gives you more control over the state management and can make testing easier. All the cases can be done with useState() method, so in conclusion, use the method that you are comfortable with, and it is easier to understand for you and colleagues

Github view