Performance: Context key patterns
MEDIUM IMPACT
This affects how efficiently components share data without prop drilling, impacting initial load and interaction responsiveness.
const key = Symbol('myKey'); setContext(key, value); // In child const value = getContext(key);
const key = {}; setContext(key, value); // In child const value = getContext(key);
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Object literal as context key | Extra context lookups | Multiple reflows | Higher paint cost due to layout thrashing | [X] Bad |
| Symbol as context key | Minimal context lookups | Single reflow | Lower paint cost with stable layout | [OK] Good |