React · Middle · Question 22 of 75
Why split context into StateContext and DispatchContext?
- ✓Correct answer: Components reading only
dispatchdon't re-render when data changes - 2React doesn't allow putting both data and functions into one context
- 3So that
dispatchworks asynchronously, as in Redux Thunk
Explanation
dispatch from useReducer is stable and never changes. If you put it into a separate context, "add" and "delete" buttons that read only it won't re-render on every data change. It's a common technique for scaling "reducer + context".