vercel-composition-patterns

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

Updated Aug 5, 2024
One-click install
npx skills add https://github.com/SethyRung/movie-next --skill vercel-composition-patterns-sethyrung
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/SethyRung/movie-next/tree/main/.agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/SethyRung/movie-next --skill vercel-composition-patterns-sethyrung

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 rules for replacing prop proliferation with compound components, lifted state, and dependency-injected context interfaces. ## Core Features & Use Cases - Boolean Prop Elimination: Replace boolean prop combinations with explicit variant components and compound component structures backed by shared context. - State Lifting & Dependency Injection: Move state into provider components with generic state/actions/meta interfaces so the same UI works with different state implementations. - React 19 API Guidance: Apply React 19 conventions such as ref as a regular prop and use() instead of useContext(). - Use Case: When refactoring a Composer component overloaded with isThread, isEditing, and isForwarding flags, apply these rules to split it into ThreadComposer, EditComposer, and ForwardMessageComposer variants sharing a common context provider. ## Quick Start Ask the AI to refactor a React component that has too many boolean props using the composition patterns in this skill.

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 React components with too many boolean props?

Replace boolean props with explicit variant components that compose shared internals. Create separate components like ThreadComposer or EditComposer, each composing the pieces it needs from a compound component structure instead of passing flags to one monolithic component.

What are compound components in React?

Compound components are a set of subcomponents sharing state through a common context rather than props. Consumers compose the pieces they need, such as Composer.Frame, Composer.Input, and Composer.Submit, with no hidden conditionals or prop drilling.

Should I use children or render props for React composition?

Use children when composing static structure because they are more readable and compose naturally. Reserve render props for cases where the parent must pass data back to the child, such as rendering list items with per-item data.

Does React 19 still require forwardRef?

No. In React 19, ref is a regular prop, so you can accept it directly in the function signature without the forwardRef wrapper. React 19 also replaces useContext() with the use() hook, which can be called conditionally.

How do I share React state with components outside the main UI?

Lift state into a provider component that wraps the entire subtree. Any component inside the provider boundary, even siblings outside the main UI like dialog action buttons, can access state and actions through the shared context.