Performance: Reactive objects with reactive
MEDIUM IMPACT
This affects how Vue tracks changes in objects and updates the DOM efficiently.
const state = reactive({ user: { name: 'Alice', age: 30 } }); // Use Vue's reactive system properly; mutations are tracked efficiently state.user.name = 'Bob';
const state = ref({ user: { name: 'Alice', age: 30 } }); // Directly mutating nested properties without reactivity helpers state.value.user.name = 'Bob';
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Direct nested mutation without optimization | Multiple DOM updates | Multiple reflows | High paint cost | [X] Bad |
| Reactive object with minimal nested changes | Single DOM update | Single reflow | Low paint cost | [OK] Good |