Performance: How Vue tracks dependencies automatically
MEDIUM IMPACT
This affects how efficiently Vue updates the UI by tracking which parts of the data each component uses, minimizing unnecessary work.
const state = reactive({ count: 0, name: 'Vue' }); watchEffect(() => { console.log(state.count); }); // Vue tracks only 'count' dependency, ignoring 'name' changes.
const state = reactive({ count: 0, name: 'Vue' }); watchEffect(() => { console.log(state.count, state.name); }); // This logs whenever any reactive property changes, even if only one is needed.
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Tracking all reactive properties regardless of usage | High (many updates) | Multiple per unrelated change | High (many repaints) | [X] Bad |
| Tracking only accessed reactive properties automatically | Low (targeted updates) | Single per relevant change | Low (minimal repaints) | [OK] Good |