react-component-composition

Structure React component APIs using composition, compound components, and render props.

Updated Jul 27, 2026
One-click install
npx skills add https://github.com/arayaroma/ether --skill react-component-composition-arayaroma
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: react-component-composition
Source: https://github.com/arayaroma/ether/tree/main/skills/react-component-composition
Command: npx skills add https://github.com/arayaroma/ether --skill react-component-composition-arayaroma

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? React components often grow unwieldy as they accumulate boolean and variant props, or when sibling components need to share implicit state without prop drilling. This Skill provides concrete patterns for designing flexible component APIs that stay maintainable as requirements grow. ## Core Features & Use Cases - Composition over inheritance: Split large components into small pieces like Card, CardHeader, and CardBody instead of one component with many flags. - Compound components: Coordinate siblings like Tabs and Tab through React Context so they share state without prop drilling. - Render props: Let a component own async or derived state while the caller controls how each phase (loading, error, data) renders. - Use Case: When a Button component has grown to accept ten boolean props like isPrimary, isLarge, and hasIcon, refactor it into composable sub-components, or when building a Tabs interface where Tab items must read and update the active tab. ## Quick Start Refactor this React component that has too many boolean props into composable sub-components using composition patterns.

Frequently Asked Questions about react-component-composition

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

FAQPage Schema
How do I refactor a React component with too many props?▼

Split the component into small composable pieces like Card, CardHeader, and CardBody instead of one component with many boolean flags. Callers assemble the pieces they need, so new variants do not require new props.

What are compound components in React?▼

Compound components are sibling components like Tabs and Tab that share implicit state through React Context instead of prop drilling. The parent provides a context value, and children consume it, throwing an error if used outside the provider.

When should I use render props vs custom hooks in React?▼

Prefer a custom hook returning {data, loading, error} for new code. Render props mainly survive in older codebases or when the rendering markup genuinely varies per call site and the component owns async state.

How do React components share state without prop drilling?▼

Use the compound component pattern: create a Context in the parent component, provide the shared state and setter, and let child components consume it with useContext. This avoids passing props through intermediate layers.

When should I avoid render props in React?▼

Avoid render props for new code when a custom hook can expose the same state, since hooks are simpler to compose and test. Render props fit only when the caller needs full control over markup for each async phase.