composition-patterns

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

2|Updated Jul 25, 2026
One-click install
npx skills add https://github.com/ankaboot-source/boucle --skill composition-patterns-ankaboot-source
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: composition-patterns
Source: https://github.com/ankaboot-source/boucle/tree/main/.jcode/skills/composition-patterns
Command: npx skills add https://github.com/ankaboot-source/boucle --skill composition-patterns-ankaboot-source

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 concrete patterns to replace prop proliferation with composition, making component libraries 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. - Dependency-Injectable State: Define generic context interfaces with state, actions, and meta so the same UI works with local state, Zustand, or server sync. - React 19 API Guidance: Apply modern patterns like ref-as-prop and use() instead of forwardRef and useContext. - Use Case: When refactoring a Composer component with six boolean props into explicit ThreadComposer, EditComposer, and ForwardMessageComposer variants that share internals through a common context. ## Quick Start Refactor this React component that has too many boolean props using composition patterns with compound components and context providers.

Frequently Asked Questions about composition-patterns

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

FAQPage Schema
How do I refactor React components with too many boolean props?

Replace boolean props with composition by creating explicit variant components that compose shared internals. Each variant like ThreadComposer or EditComposer declares exactly what it renders, eliminating exponential conditional states.

What are compound components in React?

Compound components are structured as a parent provider with subcomponents that access shared state via context instead of props. Consumers compose pieces like Composer.Frame, Composer.Input, and Composer.Submit explicitly without hidden conditionals.

When should I use render props vs children in React?

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

Does React 19 still require forwardRef?

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

How do I share React state between sibling components without prop drilling?

Lift state into a provider component that wraps the siblings. Any component inside the provider boundary can access state and actions via context, even if not visually nested inside the main UI.