react-state-management

Guides placement of React state across local, context, Zustand, and TanStack Query layers.

1|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/TierOne-Studio/spa-velocity --skill react-state-management-tierone-studio
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: react-state-management
Source: https://github.com/TierOne-Studio/spa-velocity/tree/main/.ruler/skills/react-state-management
Command: npx skills add https://github.com/TierOne-Studio/spa-velocity --skill react-state-management-tierone-studio

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Choosing where state lives in a React SPA is error-prone: wrong placement causes rerender cascades, stale duplicated state, and single-source-of-truth violations. This Skill provides a four-layer decision model and hard rules to place state correctly the first time. ## Core Features & Use Cases - Four-layer decision model: Classifies state as component-local, lifted, context, Zustand store, or TanStack Query cache, with explicit promotion criteria between layers. - Hard rules and anti-patterns: Enforces server state in TanStack Query, derived state at render time, selector-based Zustand reads, and change-rate-split contexts. - Use Case: When building a feature that shares filter state across sibling components, use this Skill to decide whether to lift state, use context, or derive values, avoiding a mirrored Zustand slice that goes stale. ## Quick Start Ask the AI to review where a piece of state should live in your React feature using the react-state-management decision model.

Frequently Asked Questions about react-state-management

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

FAQPage Schema
How do I decide between useState, context, and Zustand in React?▼

Start with useState for single-component state, lift to the closest common ancestor when siblings share it, use context for cross-tree values that change infrequently, and reserve Zustand for app-wide client state like theme or current organization.

Should server data go in Zustand or TanStack Query?▼

Server state belongs in the TanStack Query cache, never mirrored into Zustand. The query cache owns fetching, revalidation, and invalidation; duplicating it into a store creates stale copies and sync bugs.

When should I lift state up in React?▼

Lift state only when a second consumer appears, and only to the closest common ancestor. Lifting preemptively in case it is needed later is a YAGNI anti-pattern that adds coupling without benefit.

Why does React context cause performance problems?▼

Every consumer rerenders when the context value changes, so high-frequency values like mouse position cause whole-tree rerenders. Split contexts by change rate, memoize provider values, and use refs or selector-based Zustand reads for frequent updates.

When should I use useReducer instead of useState?▼

Use useReducer when state transitions involve three or more actions or encode invariants, such as a wizard form. For simple two-action state, useState is sufficient and less verbose.