vercel-composition-patterns

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

3|Updated Nov 8, 2014
One-click install
npx skills add https://github.com/mintuz/.dotfiles --skill vercel-composition-patterns-mintuz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/mintuz/.dotfiles/tree/main/agents/.agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/mintuz/.dotfiles --skill vercel-composition-patterns-mintuz

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 patterns to refactor such components into composable, maintainable architectures. ## Core Features & Use Cases - Boolean Prop Elimination: Replace prop proliferation with explicit component variants and compound components sharing context. - State Management Patterns: Lift state into provider components and define generic context interfaces (state, actions, meta) for dependency injection. - React 19 Guidance: Covers modern APIs including ref as a regular prop and use() replacing useContext(). - Use Case: When refactoring a message composer with flags like isThread, isEditing, and isForwarding, apply these patterns to split it into explicit ThreadComposer, EditComposer, and ForwardComposer variants sharing compound component internals. ## Quick Start Ask the AI to refactor a React component that has too many boolean props using 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 React components 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 instead of relying on conditional logic inside one monolithic component.

What are compound components in React?

Compound components are structured as a parent provider with subcomponents that access shared state via context rather than props. Consumers compose exactly the pieces they need, such as Composer.Frame, Composer.Input, and Composer.Submit.

When should I use children instead of render props in React?

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.

Does React 19 still require forwardRef?

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

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

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