react-state-management
Standards for managing local, global, and server state.
Installation
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
View source ↗GuidesSkill instructions
React State Management
Priority: P0 (CRITICAL)
Choosing the right tool for state scope.
Implementation Guidelines
-
Local:
useState.useReducerif complex (state machine). -
Derived:
const fullName = first + last. No state sync. - Context: DI, Theming, Auth. Not for high-freq data.
- Global: Zustand/Redux for app-wide complex flow.
-
Server Cache: Use
React.cache(RSC) to dedupe requests per render. - Server State: React Query / SWR / Apollo. Cache != UI State.
- URL: Store filter/sort params in URL (Source of Truth).
- Immutability: Never mutate. Use spread or Immer.
Anti-Patterns
- No Prop Drilling > 2: Use Context/Composition.
- No Mirroring Refs: Don't copy props to state.
- No Multi-Source: Single Source of Truth.
- No Context Abuse: Context causes full-tree re-render.
Reference & Examples
For Zustand, Redux Toolkit, and TanStack Query patterns: See references/REFERENCE.md.
Related Topics
hooks | component-patterns | performance
Examples
Read the usage examples in the source repository.
View source ↗Source history
- Indexed on
- 2026-01-20
- Index updated
- 2026-01-26
- Branch
- main
Index and sync dates describe this directory. View the source repository for code history.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!