React HooksLesson 51Free preview
React useReducer
This lesson is part of React · All levels
Summary
The useReducer is a useState alternative to the more complex state, consisting of a state and a dispatch function. The dispatch sends action to a pure reducer that calculates a new state based on the previous state. This pattern separates the logic of state change so it's easier to test and predict.
Key points
- UseReducer returns the [state, dispatch]
- Reducer is a function
- Action explains the events that changed the state
- Suitable for confined states or many types of transitions
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.