react-state-management

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

Updated Jul 1, 2026
One-click install
npx skills add https://github.com/SJLee-0525/aperture --skill react-state-management-sjlee-0525
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: react-state-management
Source: https://github.com/SJLee-0525/aperture/tree/main/.claude/skills/react-state-management
Command: npx skills add https://github.com/SJLee-0525/aperture --skill react-state-management-sjlee-0525

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires zustand, jotai, @reduxjs/toolkit, react-redux, @tanstack/react-query, and includes references (resource) components.

What problem does it solve? Choosing and correctly implementing state management in React applications is confusing, with overlapping options for local, global, server, URL, and form state that lead to duplicated data, unnecessary re-renders, and tangled architectures. ## Core Features & Use Cases - Library Selection Guidance: Decision criteria for choosing between Redux Toolkit, Zustand, Jotai, and React Query based on app size, state complexity, and server interaction. - Typed Implementation Patterns: Production-ready TypeScript examples including RTK slices with createAsyncThunk, Zustand slice composition with selective subscriptions, Jotai atoms with derived and async state, and React Query with optimistic updates and query key factories. - Migration Support: Step-by-step conversion from legacy Redux boilerplate to Redux Toolkit with Immer. - Use Case: When building a dashboard that mixes UI state (sidebar, modals) with fetched server data, apply the combined client-plus-server pattern using Zustand for UI state and React Query for cached API data. ## Quick Start Ask the AI to set up global state management for your React app, for example: "Set up a Zustand store with TypeScript for user authentication and theme, and show me how to fetch server data with React Query."

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 when you need atomic granular updates. For apps with heavy server interaction, pair React Query with a light client state library.

How do I manage server state in React with React Query?▼

Use useQuery with a query key factory for fetching and caching, and useMutation for writes. React Query handles staleTime, garbage collection, and cache invalidation, so you should not duplicate server data into a client store.

How do I implement optimistic updates with React Query?▼

In useMutation's onMutate callback, cancel outgoing queries, snapshot the previous cache value, and set the new data with setQueryData. On error, roll back using the snapshot, and invalidate the query in onSettled to refetch.

Does Zustand prevent unnecessary re-renders in React?▼

Yes, Zustand supports selective subscriptions by passing a selector function to the store hook, so components only re-render when their selected slice changes. You can also export dedicated selector hooks like useUser or useCart.

How do I migrate from legacy Redux to Redux Toolkit?▼

Replace action type constants and switch-based reducers with createSlice, which generates actions automatically and uses Immer so you can write mutation-style logic safely. Add createAsyncThunk for async flows and typed useAppDispatch and useAppSelector hooks.

When should state not be put in a global store?▼

Keep state local when it is only used by one component or a small subtree, and never duplicate server-fetched data into global stores since React Query already manages it. Derived values should be computed rather than stored.