State Management · Junior · Question 10 of 75
What must a reducer function be like?
- ✓Correct answer: Pure:
(state, action) => newStatewith no side effects or mutations - 2Async: it can make requests and return a promise of the state
- 3Mutating: it changes
statedirectly and returns nothing
Explanation
React may call the reducer more than once (e.g. in Strict Mode), so it must not make requests, set timers or mutate the state. Side effects belong in event handlers or effects.