vercel-composition-patterns

Convert React boolean props into provider-based compound components with shared context.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Many React components become hard to maintain due to boolean prop proliferation, tightly coupled state implementations, and monolithic APIs that produce brittle conditional logic and duplicated variants.

Core Features & Use Cases

  • Eliminate boolean props: Replace mode flags with explicit variant components to avoid exponential state combinations.
  • Compound components & context: Build composable UI pieces that consume a shared context (state, actions, meta) provided by a parent provider.
  • Lift and decouple state: Move state into provider boundaries so sibling UI and external controls can read and act on the same data; support swapping implementations without changing UI.
  • React 19 guidance: Recommend using use() instead of useContext(), treat ref as a regular prop, and update component patterns for React 19 APIs.
  • Use Case: Refactor a chat composer or design a component library where multiple providers (local ephemeral, global synced) must reuse the same input, submit, and meta behaviors while remaining implementation-agnostic.

Quick Start

Refactor the Composer component to remove boolean props by creating a Composer.Provider that injects a generic context (state, actions, meta) and expose explicit variant components like ThreadComposer and EditComposer.

Frequently Asked Questions about vercel-composition-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I eliminate boolean prop proliferation in React components?

Compound components in React work by composing child UI pieces that consume a shared context provided by a parent provider. This context exposes generic state, actions, and meta so siblings and external controls can read and act on the same data.

How do I refactor a monolithic React component to use context providers?

Refactor a monolithic React component by defining a generic context interface, lifting state into provider boundaries, and composing children over render props. Expose explicit variant components like ThreadComposer and EditComposer instead of relying on boolean flags.

Can I use React 19 use() and ref-as-prop patterns for component composition?

Yes, React 19 composition supports using the use() API instead of useContext() and treating ref as a regular prop. Updating component patterns to these React 19 APIs ensures your compound components and context providers remain current.

What's the best way to decouple state management in a React component library?

The best way to decouple state management in a React component library is moving state into provider boundaries. This allows sibling UI and external controls to reuse the same input, submit, and meta behaviors while remaining implementation-agnostic.

When should I avoid replacing boolean props with variant components?

Avoid replacing boolean props with variant components when the conditional logic is minimal and does not produce duplicated variants or exponential state combinations. Composition refactors are best suited for monolithic APIs that have become hard to maintain.