Performance: Computed properties for derived state
MEDIUM IMPACT
This affects how efficiently the UI updates when underlying data changes, impacting rendering speed and responsiveness.
const doubled = computed(() => count.value * 2);
const doubled = ref(0); watch(() => count.value, (newVal) => { doubled.value = newVal * 2; });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Manual watcher updating derived state | Multiple reactive triggers | Multiple reflows per update | Higher paint cost due to redundant updates | [X] Bad |
| Computed property for derived state | Single reactive trigger | Single reflow per update | Lower paint cost due to caching | [OK] Good |