react-composition-patterns

Structure React components with compound components and provider-based state management.

Updated Mar 11, 2026
One-click install
npx skills add https://github.com/rafael-hc/AoPonto-FoodService --skill react-composition-patterns-rafael-hc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-composition-patterns
Source: https://github.com/rafael-hc/AoPonto-FoodService/tree/main/.agents/skills/react-composition-patterns
Command: npx skills add https://github.com/rafael-hc/AoPonto-FoodService --skill react-composition-patterns-rafael-hc

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill addresses the complexity of managing React components by providing patterns to avoid prop proliferation and create more flexible, maintainable codebases.

Core Features & Use Cases

  • Component Architecture: Avoids boolean prop proliferation and promotes the use of compound components.
  • State Management: Guides on lifting state into providers and defining generic context interfaces for dependency injection.
  • Implementation Patterns: Recommends composing children over render props and creating explicit component variants.
  • React 19 APIs: Covers changes like using use() instead of useContext() and handling refs.
  • Use Case: Refactoring a large component with many conditional rendering paths into a set of smaller, composable components that are easier to understand and maintain.

Quick Start

Apply the react-composition-patterns skill to refactor the UserProfileCard component to use compound components and lift state into a provider.

Frequently Asked Questions about react-composition-patterns

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

FAQPage Schema
How do I avoid boolean prop proliferation when structuring React components?

Avoid boolean prop proliferation in React components by utilizing compound components and creating explicit component variants instead of relying on multiple conditional flags. This architectural pattern promotes flexible and maintainable codebases by composing children over render props.

What is the best way to manage state in complex React component architecture?

The best way to manage state in complex React component architecture is by lifting state into providers and defining generic context interfaces for dependency injection. This approach isolates state management from the UI layer, making components more modular.

How do I refactor a large React component with many conditional rendering paths?

Refactor a large React component by breaking it down into a set of smaller, composable compound components. This pattern replaces deeply nested conditional rendering with explicit variants, resulting in code that is significantly easier to understand and maintain.

Does this React composition pattern support React 19 APIs like use()?

Yes, this React composition pattern supports React 19 APIs by recommending the use of `use()` instead of `useContext()` and providing updated guidelines for handling refs. These modern APIs streamline state injection and component composition.

When should I use compound components over render props in React?

You should use compound components over render props in React when you need a more maintainable and explicit component API. Composing children directly avoids the callback complexity of render props, enhancing scalability in library development and reusable UI element creation.