State Management · Middle · Question 4 of 75
How do you pass dispatch from useReducer deep into the tree without prop drilling?
- ✓Correct answer: Put
dispatchinto its own context; it never changes, so consumers don't re-render - 2Store
dispatchinlocalStorageand read it in children - 3Recreate the reducer in every child with the same initial state
Explanation
The "reducer + context" pattern: one context for state, another for dispatch. Components that only send actions (buttons, forms) read the stable dispatch context and don't re-render when the state changes.