vercel-composition-patterns

Refactor React component APIs by replacing boolean props with composition patterns.

Updated Aug 15, 2025
One-click install
npx skills add https://github.com/gesmith0606/nfl_data_engineering --skill vercel-composition-patterns-gesmith0606
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/gesmith0606/nfl_data_engineering/tree/main/web/frontend/.agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/gesmith0606/nfl_data_engineering --skill vercel-composition-patterns-gesmith0606

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Large React components often accumulate boolean props and conditional branches that create exponential state combinations, hard-to-read code, and brittle APIs. This Skill provides a structured approach to replace boolean-mode components with explicit variants, compound components, and provider-based state so UI code becomes predictable, testable, and composable.

Core Features & Use Cases

  • Compound Components & Providers: Use shared context and subcomponents so consumers compose UI pieces instead of toggling booleans.
  • State Interfaces & Dependency Injection: Define state/actions/meta interfaces so the same UI works with local state, global sync, or server-backed providers.
  • Explicit Variants & Composition Patterns: Replace monolithic multi-mode components with clear variant components (ThreadComposer, EditComposer, etc.) for better readability and fewer impossible states.
  • React 19 API Guidance: Recommendations for refs and context usage under React 19 (use() instead of useContext(), ref as a regular prop).
  • Use Case Example: Refactor a messaging Composer that has isThread, isEditing, and isForwarding booleans into a set of Provider-backed explicit composers to enable reuse and sibling components (previews, action buttons) to access shared state.

Quick Start

Refactor a MessageComposer by introducing a Composer.Provider with a state/actions/meta interface, replace boolean props with explicit variant components, and compose UI using Composer.Frame, Composer.Input, and Composer.Footer.

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?

Apply composition patterns like compound components and React context providers so consumers compose UI pieces instead of toggling boolean props and creating brittle APIs.

What is the best way to structure React state management for multi-mode components?

Replace monolithic multi-mode components with clear variant components like ThreadComposer or EditComposer to achieve better readability and fewer impossible states.

How do I use React 19 context and refs when refactoring component APIs?

React 19 API guidance recommends using the use() hook instead of useContext() and treating ref as a regular prop to streamline context usage and ref forwarding during refactors.

Can I apply these composition patterns during code reviews and component-library design?

Yes, apply these composition patterns across React codebases during refactors, component-library design, and code reviews to reduce boolean props and improve maintainability.

Why do large React components accumulate hard-to-read conditional branches?

Large React components accumulate conditional branches because boolean props create exponential state combinations, leading to hard-to-read code and brittle APIs that require composition refactoring.