useState basics, correct updates, functional updates, and common mistakes
useState stores local component state, and updates should be based on immutable patterns and previous state when needed.
- Use functional updates when next state depends on previous state
- Never mutate arrays or objects directly
- Setter calls schedule a re-render
useState basics, correct updates, functional updates, and common mistakes