vercel-composition-patterns

Replace boolean props with compound components and provider-based state in React.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Many React components become hard to maintain when they rely on multiple boolean props and monolithic conditionals; this Skill provides patterns to replace mode flags with explicit, composable component variants and provider-based state so components remain clear, testable, and easy to reason about by humans and agents.

Core Features & Use Cases

  • Composition-first patterns: Use compound components and children composition instead of boolean props or render props to make UI structure explicit.
  • Provider-based state: Lift state into providers and define a generic context interface (state, actions, meta) so the same UI works with different state implementations.
  • Explicit variants & React 19 guidance: Create clear variant components (ThreadComposer, EditComposer, etc.) and follow React 19 conventions like use() and ref-as-prop.
  • Use Case: Refactor a messaging composer to remove isEditing/isThread flags, expose a Composer.Provider, and implement ChannelComposer, ThreadComposer, and EditComposer variants.

Quick Start

Refactor the Composer component to replace boolean props with compound components and a provider-based context following the vercel-composition-patterns guidelines.

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 bloat in React components?

React boolean prop bloat is reduced by replacing mode flags with explicit compound components and provider boundaries. This pattern uses generic context interfaces for state, actions, and meta, making UI structure explicit and testable.

What is the best way to refactor a messaging composer with multiple isEditing and isThread flags?

Refactoring a messaging composer involves removing isEditing and isThread flags by exposing a Composer.Provider and implementing explicit variant components like ChannelComposer, ThreadComposer, and EditComposer to handle distinct modes independently.

How does provider-based state lifting work for compound components in React?

Provider-based state lifting works by moving state into a provider and defining a generic context interface for state, actions, and meta. This allows the same compound component UI to work seamlessly with different state implementations without prop drilling.

Can I use React 19 conventions like use() and ref-as-prop with compound component patterns?

Yes, compound component patterns are fully compatible with React 19 conventions. The approach explicitly follows React 19 API conventions such as use() for context consumption and ref-as-prop for forwarding refs within explicit variant components.

When should I not use boolean props for React component variants?

You should avoid boolean props for React component variants when components rely on multiple mode flags and monolithic conditionals, making them hard to maintain, test, and reason about by both humans and agents due to tangled logic paths.