Performance: Reactivity caveats and limitations
MEDIUM IMPACT
This affects how efficiently the UI updates in response to data changes, impacting interaction responsiveness and visual stability.
const profile = reactive({ name: 'Alice', age: 30 }); const state = reactive({ userProfile: profile }); // Update shallow reactive object directly profile.age = 31;
const state = reactive({ user: { profile: { name: 'Alice', age: 30 } } }); // Updating deeply nested property triggers full deep reactivity state.user.profile.age = 31;
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Deep reactive nested objects | High (many dependencies) | Multiple reflows per update | High paint cost due to frequent updates | [X] Bad |
| Shallow reactive objects with focused updates | Low (few dependencies) | Single reflow per update | Low paint cost | [OK] Good |
| Watcher without deep option on nested data | Missed updates or redundant triggers | Unpredictable reflows | Inconsistent paint | [!] OK |
| Using Vue reactive array methods | Correct dependency tracking | Single reflow per mutation | Consistent paint | [OK] Good |