State Management · Junior · Question 11 of 75
When is useReducer usually a better choice than several useState calls?
- ✓Correct answer: When the state has many related fields and update logic is spread over handlers
- 2Whenever the state is a single boolean flag
- 3Only when the state must be shared globally across the app
Explanation
A reducer collects all transitions in one place, so they're easy to read and test, and handlers only describe what happened. For a single toggle useState is simpler. useReducer doesn't make state global by itself.