0
Why can Context API cause performance problems, and how can you optimize it?
subina kallyani
easy
2completed
26
Answer
Every context value change re-renders all consumers, regardless of whether they use the part of the value that changed. This can cause wasted renders.
Optimizations:
- Split contexts (auth, theme, language).
- Use memoized context values.
- Use selectors (with libraries like
use-context-selector). - Combine Context with memoized children.
Click to Reveal Answer
Tap anywhere to see the solution
Revealed
Comments0