Performance: Composable with reactive state
MEDIUM IMPACT
This affects how efficiently the UI updates when reactive state changes, impacting interaction responsiveness and rendering speed.
import { ref } from 'vue'; export function useCounter() { const count = ref(0); return { count }; }
import { reactive } from 'vue'; const state = reactive({ count: 0 }); export function useCounter() { return { state }; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Shared reactive state in composable | Many components update DOM nodes | Multiple reflows triggered | High paint cost due to wide updates | [X] Bad |
| Instance-specific reactive state in composable | Only affected component updates DOM | Single reflow per update | Lower paint cost focused on small area | [OK] Good |