React · Senior · Question 21 of 75

Why doesn't useContext have "selectors", and how do people work around it?

Explanation

Any change to value re-renders everyone calling useContext, even if they need one field. Workarounds: several narrow contexts, memoized consumers, the use-context-selector library, or a store with selector subscriptions (Zustand, Redux, Jotai).

Further reading

Problem with a question

React · Senior · question 21

Test yourself

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

Take this quiz