react-patterns

Provides React patterns for hooks, composition, state management, performance, and TypeScript.

1|Updated Aug 17, 2025
One-click install
npx skills add https://github.com/ratnesh-maurya/mdconverter --skill react-patterns-ratnesh-maurya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-patterns
Source: https://github.com/ratnesh-maurya/mdconverter/tree/main/.claude/skills/react-patterns
Command: npx skills add https://github.com/ratnesh-maurya/mdconverter --skill react-patterns-ratnesh-maurya

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? React developers often struggle with inconsistent component design, unclear state management choices, and premature optimization. This Skill provides a structured reference of modern React patterns and principles to guide building maintainable, production-ready React applications. ## Core Features & Use Cases - Component Design Guidance: Defines component types (server, client, presentational, container) and rules like composition over inheritance and single responsibility. - Hook and State Patterns: Covers when to extract custom hooks, how to select state management solutions (useState, Context, React Query, Zustand), and React 19 hooks like useActionState and useOptimistic. - Performance and Quality Principles: Offers optimization order, error boundary placement, TypeScript typing patterns, testing priorities, and common anti-patterns to avoid. - Use Case: When refactoring a large React component with deep prop drilling, consult this Skill to decide whether to lift state, introduce Context, or adopt a global store like Zustand. ## Quick Start Ask the AI to review your React component and recommend appropriate patterns for state management, composition, and performance based on these React 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 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 global state. Match the tool to where the state actually lives.

When should I extract a custom React hook?

Extract a custom hook when the same logic repeats across components, such as useLocalStorage for storage access, useDebounce for debounced values, useFetch for repeated fetch patterns, or useForm for complex form state. Custom hooks must start with 'use' and follow 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 adds automatic memoization, reducing the need for manual useMemo and useCallback.

When should I use useMemo and useCallback in React?

Use useMemo for expensive calculations and useCallback for stable callback references, but only after profiling confirms a performance problem. Profile with DevTools first, identify the actual bottleneck, then apply a targeted fix rather than optimizing prematurely.

What are common React anti-patterns to avoid?

Avoid deep prop drilling (use Context instead), giant components (split them smaller), overusing useEffect (prefer server components), premature optimization (profile first), and using array indexes as keys (use stable unique IDs).