Performance: Composables for reusable logic
MEDIUM IMPACT
This affects page load speed and interaction responsiveness by controlling how reusable logic impacts component rendering and reactive updates.
import { reactive } from 'vue'; export function useCounter() { const state = reactive({ count: 0 }); return { state }; }
import { reactive } from 'vue'; const state = reactive({ count: 0 }); export function useCounter() { return { state }; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Global shared reactive state in composable | Low (few DOM nodes) | High (many reactive triggers) | Medium (frequent updates) | [X] Bad |
| Instance-scoped reactive state in composable | Low (few DOM nodes) | Low (limited reactive triggers) | Low (updates scoped) | [OK] Good |