State Management · Middle · Question 8 of 75

Why doesn't React.memo help a component that calls useContext(CartContext)?

Explanation

Context updates bypass the props comparison. A workaround: read the context in a small parent and pass only the needed value to a memoized child, so the child skips rendering when that value is unchanged.

Further reading

Problem with a question

State Management · Middle · question 8

Test yourself

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

Take this quiz