react-patterns

Guides React component design, hooks, state management, and performance optimization decisions.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? React developers often struggle with inconsistent component architecture, misplaced state, premature optimization, and anti-patterns that degrade maintainability. This Skill provides a structured reference of proven React patterns to make consistent design decisions. ## Core Features & Use Cases - Component Design Guidance: Rules for server, client, presentational, and container components with composition-first principles. - State Management Selection: Decision tables mapping complexity levels to useState, Context, React Query, Zustand, or Redux Toolkit. - React 19 & Performance Patterns: Coverage of useActionState, useOptimistic, compiler benefits, and a profile-first optimization workflow. - Use Case: When building a new feature, consult this Skill to decide where state should live, when to extract a custom hook, and which anti-patterns to avoid before writing code. ## Quick Start Review my React component structure and recommend the appropriate state management and composition patterns for this feature.

Frequently Asked Questions about react-patterns

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

FAQPage Schema
How do I choose between useState, Context, and Zustand for React state?

Choose based on complexity and scope: useState or useReducer for simple local state, Context for shared state within a subtree, React Query or SWR for server state, and Zustand or Redux Toolkit for complex app-wide state. Lift state up only when parent-child sharing is needed.

When should I extract a custom hook in React?

Extract a custom hook when the same logic repeats across components, such as localStorage access, debounced values, fetch patterns, or complex form state. Custom hooks must start with "use", be called at the top level, and clean up effects on unmount.

What are the new hooks in React 19?

React 19 introduces useActionState for form submission state, useOptimistic for optimistic UI updates, and use for reading resources during render. The React Compiler also adds automatic memoization, reducing the need for manual useMemo and useCallback.

Should I use render props or custom hooks for reusable logic?

Prefer custom hooks for reusable logic, render props when you need render flexibility, and higher-order components for cross-cutting concerns. Compound components with context work best for flexible slot-based UI like Tabs, Accordion, or Dropdown.

When should I optimize React performance with useMemo and useCallback?

Only optimize after confirming a real bottleneck: profile with DevTools first, identify the slow component, then apply targeted fixes. Virtualize large lists, use useMemo for expensive calculations, and useCallback for stable callbacks passed to memoized children.

What are common React anti-patterns to avoid?

Avoid deep prop drilling (use Context instead), giant components (split into smaller ones), overusing useEffect, premature optimization, and using array indexes as keys. Prefer stable unique IDs for keys and profile before optimizing.