vercel-composition-patterns

Guides React component refactoring using compound components, context providers, and composition patterns.

7|1|Updated Mar 29, 2024
One-click install
npx skills add https://github.com/aBgAmeuR/harmony --skill vercel-composition-patterns-abgameur
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/aBgAmeuR/harmony/tree/main/.agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/aBgAmeuR/harmony --skill vercel-composition-patterns-abgameur

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

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 composition patterns to refactor such components into flexible, maintainable architectures. ## Core Features & Use Cases - Boolean Prop Elimination: Replace prop proliferation with compound components and explicit variant components that document themselves. - State Lifting & Dependency Injection: Define generic context interfaces (state, actions, meta) so UI components work with any provider implementation. - React 19 API Guidance: Apply modern patterns like ref-as-prop and use() instead of forwardRef and useContext. - Use Case: When refactoring a messaging Composer component with flags like isThread, isEditing, and isForwarding, apply these rules to split it into explicit ThreadComposer, EditComposer, and ForwardMessageComposer variants sharing compound internals. ## Quick Start Ask the AI to refactor a React component that has too many boolean props using these composition patterns.

Frequently Asked Questions about vercel-composition-patterns

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

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

Replace boolean props with composition by creating explicit variant components like ThreadComposer or EditComposer. Each variant composes shared compound component pieces, eliminating conditional logic and impossible states.

What are compound components in React?

Compound components are a pattern where a parent component shares state with subcomponents via context instead of props. Consumers compose pieces like Composer.Frame, Composer.Input, and Composer.Submit explicitly without prop drilling.

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 forwardRef still work in React 19?

React 19 makes ref a regular prop, so forwardRef wrappers are no longer needed. The guidance also recommends use() instead of useContext(), which can additionally be called conditionally.

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 for sharing state.