react-patterns

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

1|Updated Aug 4, 2026
One-click install
npx skills add https://github.com/Hamzaoui-Louai/LEAN-gym-dashboard-frontend --skill react-patterns-hamzaoui-louai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-patterns
Source: https://github.com/Hamzaoui-Louai/LEAN-gym-dashboard-frontend/tree/main/.opencode/skills/react-patterns
Command: npx skills add https://github.com/Hamzaoui-Louai/LEAN-gym-dashboard-frontend --skill react-patterns-hamzaoui-louai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? React developers often struggle with inconsistent component architecture, unclear state management choices, and premature or missing performance optimizations. This Skill provides structured decision tables and principles for building maintainable React applications. ## Core Features & Use Cases - Component Design Guidance: Defines component types (server, client, presentational, container) and composition rules for clean architecture. - State Management Selection: Maps complexity levels to appropriate solutions, from useState and Context to React Query, Zustand, and Redux Toolkit. - React 19 & Performance Patterns: Covers new hooks like useActionState and useOptimistic, plus a profile-first optimization workflow. - Use Case: When building a new feature, consult the decision tables to choose between Context and a global store, decide when to extract a custom hook, and apply error boundaries at the right scope. ## Quick Start Ask the AI to review your React component structure and recommend state management and composition patterns based on these principles.

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 Context and Zustand for React state management?

Use Context for state shared within a subtree and Zustand or Redux Toolkit for complex global state. For simple local state use useState or useReducer, and for server state use React Query or SWR.

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" and follow standard hook rules.

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 reduces 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. Hooks are the default choice in modern React codebases.

When should I optimize React performance with useMemo?

Only optimize after profiling confirms a bottleneck. First check if rendering is actually slow, profile with DevTools, identify the bottleneck, then apply targeted fixes like useMemo for expensive calculations or virtualization for large lists.

Where should I place error boundaries in a React app?

Place error boundaries at the root for app-wide coverage, at route or feature level for feature isolation, or around individual risky components. Always show fallback UI, log the error, and offer a retry option.