react-state-management

Implement React state management with Redux Toolkit, Zustand, Jotai, and React Query.

1|Updated Aug 17, 2025
One-click install
npx skills add https://github.com/ratnesh-maurya/mdconverter --skill react-state-management-ratnesh-maurya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-state-management
Source: https://github.com/ratnesh-maurya/mdconverter/tree/main/.claude/skills/react-state-management
Command: npx skills add https://github.com/ratnesh-maurya/mdconverter --skill react-state-management-ratnesh-maurya

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Choosing and implementing the right state management approach in React is confusing, with overlapping options for local, global, server, URL, and form state. This Skill provides concrete patterns and selection criteria so you can set up stores, server-state caching, and optimistic updates without trial and error. ## 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 complexity. - Ready-to-Use Patterns: TypeScript implementations for Redux slices with async thunks, Zustand slice composition, Jotai atoms, and React Query hooks with optimistic updates. - Migration Support: Step-by-step guidance for migrating legacy Redux boilerplate to modern Redux Toolkit. - Use Case: When building a dashboard that needs both UI state (sidebar, modals) and server data (users, stats), use this Skill to combine Zustand for client state with React Query for server state, including cache invalidation and rollback on failed mutations. ## Quick Start Ask the AI to set up a Zustand store with TypeScript 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 apps with 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 data, and set the new value with setQueryData. On error, roll back using the snapshot from context, and invalidate the query in onSettled to refetch.

Should I use React Query or Redux for server state?

Use React Query for server state since it handles caching, refetching, and staleness automatically. Reserve Redux Toolkit or Zustand for client-only state like UI preferences, and avoid duplicating server data in global stores.

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 their selected slice changes rather than on any store update.

How do I migrate from legacy Redux to Redux Toolkit?

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

When should state not be put in a global store?

Keep state local when it is only used by one component or its children, such as form inputs or toggle states. Also avoid storing derived data that can be computed, and never duplicate server state that React Query already manages.