state-management
Installation
SKILL.md
State Management
Use the right tool for the right type of state.
1. State Classification
| Type | Description | Tool |
|---|---|---|
| Local UI | Component-only (open/closed, hover) | useState |
| Shared UI | Cross-component, no server | Zustand / Jotai / Context |
| Server/Async | Data from API, loading/error states | TanStack Query / SWR |
| URL | Navigation state, shareable | URLSearchParams / router |
| Form | Input values, validation | React Hook Form |
| Persistent | Survives page reload | localStorage + store |