react-state-management

Implements React state management patterns using Redux Toolkit, Zustand, Jotai, and React Query.

Updated Aug 11, 2026
One-click install
npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill react-state-management-duccuong159
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-state-management
Source: https://github.com/DucCuong159/Realtime-chatapp/tree/main/.agent/skills/react-state-management
Command: npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill react-state-management-duccuong159

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Choosing and implementing the right state management approach in React is confusing, and mixing server state with client state often leads to duplicated data, unnecessary re-renders, and hard-to-debug bugs. ## Core Features & Use Cases - Library Selection Guidance: Decision criteria for choosing between Redux Toolkit, Zustand, Jotai, and React Query based on app size and state type. - Typed Implementation Patterns: Production-ready TypeScript patterns including RTK slices with async thunks, Zustand slice composition, Jotai atoms, and React Query optimistic updates with rollback. - Migration Support: Step-by-step guidance for migrating legacy Redux boilerplate to Redux Toolkit. - Use Case: When building a dashboard that needs both UI state (sidebar toggles, modals) and server data (user lists, stats), use this Skill to separate concerns with Zustand for client state and React Query for server state. ## Quick Start Ask the AI to set up a typed Zustand store with persistence for user authentication state in your React app.

Frequently Asked Questions about react-state-management

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I choose between Redux Toolkit, Zustand, and Jotai?

Choose Zustand or Jotai for small apps with simple state, Redux Toolkit for large apps with complex state, and Jotai for atomic granular updates. For heavy server interaction, pair React Query with a light client state solution.

How do I implement optimistic updates with React Query?

Use the onMutate callback to cancel outgoing queries, snapshot the previous value, and set the new data optimistically. On error, roll back using the snapshot from context, then invalidate the query onSettled to refetch.

Should I use React Query or Redux for server state?

Use React Query for server state since it handles caching, staleness, and refetching automatically. Reserve Redux Toolkit or Zustand for client-only state like UI toggles and form drafts, avoiding duplicated server data.

How do I prevent unnecessary re-renders with Zustand?

Use selective subscriptions by passing a selector function to the store hook, such as useStore((state) => state.user). Components then only re-render when the selected slice changes, not on every store update.

How do I migrate legacy Redux to Redux Toolkit?

Replace action type constants and switch statements with createSlice, which generates actions automatically and uses Immer for mutable-style updates. Use createAsyncThunk for async logic instead of manual thunk middleware.

When should state not be put in a global store?

Avoid globalizing component-specific UI state, derived data that can be computed, and server data that React Query should own. Colocate state as close to where it is used as possible.