Performance: Reactive data with ref
MEDIUM IMPACT
This affects how efficiently Vue tracks and updates changes in reactive data, impacting rendering speed and responsiveness.
import { ref } from 'vue'; const count = ref(0); function increment() { count.value++; }
const count = reactive({ value: 0 }); function increment() { count.value++; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using reactive for primitive | More proxy layers, deeper tracking | Potentially more reflows if updates cascade | Higher paint cost due to extra updates | [X] Bad |
| Using ref for primitive | Minimal proxy, direct tracking | Single reflow per update | Lower paint cost with targeted updates | [OK] Good |