State Management · Middle · Question 8 of 75
Why doesn't React.memo help a component that calls useContext(CartContext)?
- ✓Correct answer: Memo compares props, but a context change re-renders the consumer regardless
- 2Memo is ignored for components that use any hooks
- 3Memo works only for class components
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.