React State Patterns

Guide React state management with patterns for global and local state.

Updated Feb 18, 2026
One-click install
npx skills add https://github.com/SamuelSaha/Reqflow --skill react-state-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: React State Patterns
Source: https://github.com/SamuelSaha/Reqflow/tree/main/SWARM/skills/foundation/react-state-patterns
Command: npx skills add https://github.com/SamuelSaha/Reqflow --skill react-state-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers understand and implement effective state management patterns in React applications, preventing common pitfalls like prop drilling and unnecessary re-renders.

Core Features & Use Cases

  • State Location Guidance: Provides a decision tree for choosing between global and local state.
  • Pattern Examples: Demonstrates common patterns like lifting state, deriving local aliases, and using URL as a state source.
  • Anti-Pattern Identification: Highlights common mistakes to avoid in state management.
  • Use Case: A developer is unsure whether to use useState, useReducer, or a global state manager like Zustand for a new feature. This Skill guides them to the most appropriate solution based on the state's scope and requirements.

Quick Start

Explain the difference between local and global state in React and provide an example of when to use each.

Frequently Asked Questions about React State Patterns

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

FAQPage Schema
When should I use global state instead of local state in React?

React global state is needed when data is accessed by many unrelated components, whereas local state suffices for isolated UI elements. This Skill helps you decide by providing a decision tree based on state scope and component hierarchy to prevent prop drilling and unnecessary re-renders.

How do I avoid prop drilling in React applications?

Avoid prop drilling in React by lifting state to a common ancestor, using the Context API, or adopting a global state manager like Zustand. This Skill demonstrates these state management patterns and illustrates deriving local aliases to pass data efficiently.

Should I use useState, useReducer, or Zustand for my new React feature?

Choose useState for simple local values, useReducer for complex state logic, and Zustand for global state shared across distant components. This Skill guides you to the most appropriate React state management solution based on your specific scope and requirements.

What are common React state management anti-patterns to avoid?

Common React state anti-patterns include excessive prop drilling, unnecessary global state, and causing avoidable re-renders. This Skill identifies these mistakes and highlights security considerations for safe state handling within your React application architecture.

Can I use the URL as a state source in React?

Using the URL as a state source in React allows you to synchronize state with browser history for shareable links. This Skill demonstrates this pattern alongside other common state management techniques like lifting state and deriving local aliases.

Does the Context API work well for all global state in React?

The Context API works well for low-frequency global state updates in React but can cause unnecessary re-renders if used for high-frequency changes. This Skill helps evaluate whether the Context API or a dedicated state manager like Zustand fits your requirements.