Performance: Why state management matters
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.
Jump into concepts and practice - no test required
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 |
const count = signal(0); matches Angular's official pattern.const count = signal(0); count.set(5); console.log(count());
count starts at 0, then is updated to 5 using count.set(5).count() returns the current value, which is 5 after the update.const user = signal({ name: 'Alice' });
user().name = 'Bob';
console.log(user().name);user().name directly mutates the object but does not trigger signal reactivity.