React · Middle · Question 22 of 75

Why split context into StateContext and DispatchContext?

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".

Further reading

Problem with a question

React · Middle · question 22

Test yourself

Take the React · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz