Performance: Why state management matters
HIGH IMPACT
State management affects how quickly the UI updates and how smoothly user interactions feel by controlling when and what parts of the page re-render.
const count = signal(0); function increment() { count.update(prev => prev + 3); } // Single state update batching changes
const count = signal(0); function increment() { count.set(count() + 1); count.set(count() + 2); } // Multiple state updates cause multiple re-renders
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple rapid state updates | Many DOM updates | Multiple reflows | High paint cost | [X] Bad |
| Batched state updates | Minimal DOM updates | Single reflow | Low paint cost | [OK] Good |