vercel-composition-patterns

Refactor React component APIs to replace boolean props with compound components and providers.

885|108|Updated Apr 30, 2025
One-click install
npx skills add https://github.com/legions-developer/invoicely --skill vercel-composition-patterns-legions-developer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/legions-developer/invoicely/tree/main/.agents/skills/composition-patterns
Command: npx skills add https://github.com/legions-developer/invoicely --skill vercel-composition-patterns-legions-developer

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It prevents React component APIs from becoming hard to understand and maintain when boolean prop proliferation and tightly-coupled state logic create unmanageable conditional rendering paths.

Core Features & Use Cases

  • Replace boolean-prop modes with explicit composition: Use compound components and explicit variants instead of “one component, many boolean states.”
  • Lift state into providers: Move state management into provider components so multiple sibling UI pieces can share state and actions without prop drilling.
  • Define context contracts for dependency injection: Standardize context as a contract of state, actions, and meta so UI consumes interfaces rather than specific state implementations.
  • Use children for composable structure: Prefer composing with children over renderX props for clearer, more flexible APIs.
  • Align with React 19+ APIs: Follow React 19 guidance such as using use() rather than useContext() and treating ref as a regular prop instead of relying on forwardRef.

Use cases (examples): Refactoring an editor/composer component with flags like isEditing and isForwarding, designing a reusable component library with compound subcomponents, or updating context usage to a provider-driven architecture compatible with React 19.

Quick Start

Use the vercel-composition-patterns skill to refactor your React component by removing boolean props, introducing explicit variants and compound subcomponents, and moving state behind a provider-driven context contract.

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 to avoid boolean prop proliferation?

Refactor React components to eliminate boolean prop proliferation by replacing conditional flags with compound components and explicit variants, lifting shared state into context providers to create maintainable and composable UIs.

What is the best way to manage shared state across sibling React components without prop drilling?

Lift state into context providers to allow sibling UI pieces to share state and actions without prop drilling, standardizing context as a contract of state, actions, and meta for dependency injection.

How do I use React 19 conventions for context and refs?

Align with React 19 conventions by using the use() hook for context instead of useContext() and treating ref as a regular prop instead of relying on the forwardRef API.

When should I use children vs render props for React component composition?

Prefer composing component structure with children over renderX props to create clearer and more flexible React component APIs, reducing tightly-coupled state logic and unmanageable conditional rendering paths.

Does this refactoring approach apply to component libraries built with TypeScript?

Yes, the refactoring approach applies to TypeScript component libraries by designing reusable components with compound subcomponents, generic context interfaces, and explicit variants for React 19+ codebases.

Why does my React component API become hard to maintain with multiple boolean flags?

Boolean prop proliferation and tightly-coupled state logic create unmanageable conditional rendering paths, making React component APIs hard to understand and maintain without refactoring to explicit composition.