vercel-composition-patterns

Refactor React components from boolean props to compound components with context providers.

Updated May 18, 2026
One-click install
npx skills add https://github.com/yogaprasetya22/mmorpg --skill vercel-composition-patterns-yogaprasetya22
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/yogaprasetya22/mmorpg/tree/main/frontend/.agents/skills/composition-patterns
Command: npx skills add https://github.com/yogaprasetya22/mmorpg --skill vercel-composition-patterns-yogaprasetya22

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you stop React component complexity from growing when behavior is controlled by many boolean props, and it guides you toward composable component design that supports maintainability and reuse.

Core Features & Use Cases

  • Eliminates boolean prop proliferation by using explicit variants that render only the UI and actions relevant to a given mode.
  • Uses compound components with shared context so subcomponents receive state/actions/meta via a provider instead of prop drilling.
  • Lifts state into provider components to enable sibling or external UI (like previews and buttons) to read and act on shared state.
  • Decouples UI from state implementation so the same components work with local state, global synced state, or server-driven data.
  • Introduces a generic context interface (state/actions/meta) to enable dependency-injected providers.
  • Applies children over render props for cleaner composition, while reserving render props for cases where data needs to flow downward.
  • Aligns with React 19 APIs by using use() for context access and treating ref as a regular prop.

Quick Start

Use the vercel-composition-patterns skill to refactor a complex React component that currently uses boolean props into explicit variant components that share state through a context provider.

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?

To refactor React components with boolean prop proliferation, extract shared state and actions into a context provider, then compose UI through compound subcomponents that consume state explicitly instead of toggling behavior with boolean props. Use explicit variants to render only relevant UI per mode.

What's the best way to share state across React compound components without prop drilling?

The best way to share state across compound components is lifting it into a provider component that exposes a generic context interface of state, actions, and meta. Sibling subcomponents then consume this shared context directly instead of receiving data through prop drilling.

When should I use compound components instead of render props in React?

Use compound components with children-based composition for cleaner React APIs when you need to compose UI elements together. Reserve render props only for cases where data needs to flow downward to children, as children-based composition provides a more maintainable and scalable API.

Does React 19 change how context providers and refs work in compound components?

React 19 changes context providers and refs by allowing you to use the use() hook for context access instead of useContext, and treats ref as a regular prop rather than requiring forwardRef. This simplifies wiring shared state through provider components in compound component architectures.

Can I decouple React component UI from state implementation using context providers?

Yes, you can decouple React component UI from state implementation by defining a generic context interface with state, actions, and meta. This dependency-injected provider pattern lets the same components work seamlessly with local state, global synced state, or server-driven data.

Why does my React component become hard to maintain when adding boolean props?

React components become hard to maintain when boolean props proliferate because they create combinatorial complexity in behavior logic. Refactoring toward composition-based design with explicit variants ensures components render only the UI and actions relevant to a given mode, reducing unexpected state combinations.