Design Patterns · Middle · Question 45 of 75
How is useReducer close to the State pattern?
- ✓Correct answer: Transitions in one place: new state = f(current, action)
- 2
useReducerstores state globally for the whole app - 3
useReducerautomatically syncs state with the server
Explanation
A reducer is a state machine's transition function. You can forbid invalid transitions (ignore submit in the loading state). For complex scenarios, explicit state machines (XState) are used.