vercel-composition-patterns

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

2|1|Updated Apr 17, 2025
One-click install
npx skills add https://github.com/abraham-yusuf/pernikahan-web --skill vercel-composition-patterns-abraham-yusuf
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/abraham-yusuf/pernikahan-web/tree/main/.agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/abraham-yusuf/pernikahan-web --skill vercel-composition-patterns-abraham-yusuf

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 rules for replacing prop proliferation with composition patterns. ## Core Features & Use Cases - Boolean Prop Elimination: Replace boolean props with explicit variant components and compound component structures. - State Lifting & Dependency Injection: Move state into provider components with generic context interfaces (state, actions, meta) so UI works with any state 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, use this Skill to restructure it into explicit ThreadComposer, EditComposer, and ForwardComposer variants sharing compound internals. ## 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. Instead of one Composer with isThread and isEditing flags, create ThreadComposer and EditComposer variants that each compose the pieces they need from a compound component.

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 exactly the pieces they need, like Composer.Frame, Composer.Input, and Composer.Submit, without hidden conditionals.

Should I use children or render props for React composition?

Use children for 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.

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 state between sibling React components without prop drilling?

Lift state into a provider component that wraps the siblings. Components inside the provider boundary access state and actions through context, even if they are not visually nested inside the main UI.