Performance: Consuming context
MEDIUM IMPACT
This affects interaction responsiveness and rendering speed when components read shared data.
Split context into smaller contexts or use memoized selectors to consume only needed parts. const value = useContext(MyContext); const selected = useMemo(() => value.part, [value.part]);
const value = useContext(MyContext); // used in many components deeply nested // context value changes frequently
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Single large context with frequent changes | Many components re-render | Multiple reflows per update | High paint cost | [X] Bad |
| Split context or memoized selectors | Only necessary components re-render | Single or few reflows | Lower paint cost | [OK] Good |