react-composition-patterns

Refactors React components using compound components, context providers, and composition patterns.

Updated Sep 15, 2026
One-click install
npx skills add https://github.com/Peterson-Benhame/agent-skills --skill react-composition-patterns-peterson-benhame
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-composition-patterns
Source: https://github.com/Peterson-Benhame/agent-skills/tree/main/packages/skills-catalog/skills/%28architecture%29/react-composition-patterns
Command: npx skills add https://github.com/Peterson-Benhame/agent-skills --skill react-composition-patterns-peterson-benhame

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? React components often accumulate boolean props like isThread or isEditing, creating exponential state combinations and unmaintainable conditional logic. This Skill provides structured patterns to replace prop proliferation with composition, making component codebases easier to maintain and extend. ## Core Features & Use Cases - Compound Component Architecture: Structure complex components with shared context so consumers compose exactly the pieces they need without prop drilling. - State Lifting and Dependency Injection: Move state into provider components with generic state/actions/meta interfaces, letting the same UI work with local state, Zustand, or server sync. - React 19 API Guidance: Apply modern patterns like ref as a regular prop and use() instead of useContext or forwardRef. - Use Case: When refactoring a message composer that has grown boolean props for thread, edit, and forward modes, use this Skill to split it into explicit ThreadComposer, EditComposer, and ForwardComposer variants sharing compound internals. ## Quick Start Ask the agent to refactor a component with many boolean props into compound components with a shared context provider following these composition patterns.

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 in React components?

Replace boolean props like isThread or isEditing with composition by creating explicit variant components such as ThreadComposer and EditComposer. Each variant composes shared compound internals, eliminating exponential conditional logic.

What are compound components in React?

Compound components are a set of subcomponents sharing state through a common context rather than props. Consumers compose pieces like Composer.Frame, Composer.Input, and Composer.Submit explicitly, with no hidden conditionals.

Should I use children or render props for React composition?

Prefer children for composing static structure since they are more readable and compose naturally. Use render props only when the parent must pass data back to the child, such as rendering list items.

Does React 19 still require forwardRef?

No, in React 19 ref is a regular prop, so forwardRef is unnecessary. The use() hook also replaces useContext() and can be called conditionally, unlike useContext.

When should I lift state into a provider component?

Lift state into a provider when sibling components outside the main UI need access to that state or its actions. This avoids prop drilling, useEffect syncing, and ref-based workarounds.

When should I not use these composition patterns?

Do not use this Skill for React or Next.js performance optimization; use a dedicated performance skill instead. These patterns target component architecture and maintainability, not rendering performance.