react-patterns

Provide pattern-based guidance for scalable React component, state, and data-fetching architecture.

1|1|Updated Mar 26, 2026
One-click install
npx skills add https://github.com/PedroHBO/opencode-config-skills --skill react-patterns-pedrohbo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-patterns
Source: https://github.com/PedroHBO/opencode-config-skills/tree/main/skills/react-patterns
Command: npx skills add https://github.com/PedroHBO/opencode-config-skills --skill react-patterns-pedrohbo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

React development often suffers from scattered patterns and inconsistent architectures, making it hard to scale UI, manage state, and fetch data efficiently.

Core Features & Use Cases

  • Component patterns (compound components, render props) for flexible UI composition
  • Custom hooks for reusable logic (state, effects, data fetching)
  • State management patterns (Context + Reducer, Redux Toolkit) for feature/global state
  • React Query patterns for server state and caching
  • Performance optimization (memoization, lazy loading, useMemo/useCallback)
  • Form handling and testing patterns (React Hook Form + Zod, Testing Library)
  • OpenCode usage templates and checklists for reviews

Quick Start

Explore the component patterns by building a small tabbed interface using a shared context and reusable subcomponents.

Frequently Asked Questions about react-patterns

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

FAQPage Schema
What React patterns should I use for building scalable UI components?

For scalable React UIs, use compound components and render props to achieve flexible composition. These patterns allow you to share implicit state across subcomponents via a shared context, keeping your component architecture clean and highly reusable.

How do I manage state in a React application using Context and Redux Toolkit?

You can manage state by applying Context + Reducer for localized feature state and Redux Toolkit for global state. These state management patterns ensure predictable data flow and help maintain scalable architectures across complex React applications.

What's the best way to fetch and cache server state with React Query?

The best way to handle server state and caching is by implementing dedicated React Query patterns. This approach separates server data from client state, providing robust data fetching mechanisms, automatic cache invalidation, and synchronous UI updates.

How do I optimize React performance using memoization and lazy loading?

Optimize React performance by applying memoization techniques with useMemo and useCallback to prevent unnecessary re-renders. Combine this with lazy loading to split your component bundles, reducing the initial load time for scalable user interfaces.

Does this React component guidance include form handling and testing strategies?

Yes, the guidance includes form handling and testing patterns utilizing React Hook Form with Zod for validation. It also covers Testing Library strategies to ensure your component logic, state management, and data fetching implementations remain robust.

When should I use custom hooks for reusable logic in React?

You should use custom hooks when you need to extract and reuse state, effects, or data fetching logic across multiple components. This pattern isolates complex business logic from your UI, promoting cleaner component structures and easier maintenance.