vercel-composition-patterns

Standardize React component composition to reduce boolean prop proliferation.

6|Updated Mar 24, 2019
One-click install
npx skills add https://github.com/rafifos/dotfiles --skill vercel-composition-patterns-rafifos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/rafifos/dotfiles/tree/main/dot_agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/rafifos/dotfiles --skill vercel-composition-patterns-rafifos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Composition patterns tackle the challenge of scaling React UI code by reducing boolean prop proliferation and enabling flexible, reusable component APIs through compound components, lifted state, and context-driven composition.

Core Features & Use Cases

  • Explicit variants for features and UI: ThreadComposer, EditMessageComposer, ForwardMessageComposer
  • Shared context with provider-based state, enabling UI components to be composed independently of state implementation.
  • Guidance for React 19 APIs including use() over useContext and avoiding forwardRef for modern patterns.
  • Use cases include refactoring large component libraries, building reusable design systems, and designing flexible APIs for complex UIs.

Quick Start

Create explicit variant components (e.g., ThreadComposer, EditMessageComposer, ForwardMessageComposer) and wrap them with the appropriate Provider, then compose your UI with the frame, header, input, and footer subcomponents.

Frequently Asked Questions about vercel-composition-patterns

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

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

Reduce boolean prop proliferation in React components by applying composition patterns. Create explicit variant components like ThreadComposer and EditMessageComposer to replace conditional logic with clear, self-contained UI elements.

What is the best way to build reusable React design system APIs?

Build reusable React design system APIs by implementing compound components with shared context. Lift state into context providers so UI subcomponents compose independently of state implementation details.

How do I use React 19 context providers for compound components?

Use React 19 context providers for compound components by adopting the use() API over useContext and avoiding forwardRef. Wrap explicit variant components with providers to manage state cleanly.

When should I use explicit variant components over conditional rendering?

Use explicit variant components over conditional rendering when scaling UI libraries or building complex interfaces. Variants prevent boolean prop bloat and decouple state implementation from composed UI subcomponents.

Does this composition pattern require forwardRef for React 19?

This composition pattern avoids forwardRef for React 19. It leverages modern API usage including the use() hook instead of useContext to handle context-driven state within compound components.

How do I refactor a React UI library to use composition patterns?

Refactor a React UI library by replacing boolean props with explicit variant components and provider-based state. Wrap variants with appropriate Providers and compose UI using frame, header, and input subcomponents.