Performance: Shallow ref and shallow reactive
MEDIUM IMPACT
This affects how Vue tracks changes and updates the DOM, impacting rendering speed and responsiveness.
const state = shallowReactive({ user: { name: 'Alice', age: 30, address: { city: 'NY', zip: '10001' } } });
const state = reactive({ user: { name: 'Alice', age: 30, address: { city: 'NY', zip: '10001' } } });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Deep reactive/ref | Many nested watchers | Multiple reflows on nested changes | High paint cost due to frequent updates | [X] Bad |
| Shallow reactive/ref | Watchers only on top-level | Single reflow per top-level change | Lower paint cost, fewer updates | [OK] Good |