vercel-composition-patterns

Apply React composition patterns to reduce boolean props in component libraries.

1|Updated Nov 9, 2024
One-click install
npx skills add https://github.com/marnec/ripple --skill vercel-composition-patterns-marnec
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/marnec/ripple/tree/main/.claude/skills/vercel-composition-patterns
Command: npx skills add https://github.com/marnec/ripple --skill vercel-composition-patterns-marnec

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Proliferation of boolean props and fragile conditional logic in React components slows development and increases maintenance costs. Vercel composition patterns provide a disciplined approach using explicit variants, compound components with shared context, and provider-based state management to scale UI libraries.

Core Features & Use Cases

  • Explicit variants demonstrate clear usage without boolean flags (e.g., ThreadComposer, EditMessageComposer, ForwardMessageComposer).
  • Compound components with shared context enable flexible composition without prop drilling.
  • State lifting into providers centralizes state management and enables reuse across different UI framings.
  • React 19 API guidance is included, with use() context usage and forwardRef avoidance as applicable.

Quick Start

Create explicit variant components (ThreadComposer, EditMessageComposer, ForwardMessageComposer) that share a single Frame and ContextProvider to build a scalable UI library.

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 creating explicit variant components instead of relying on conditional flags. Build separate components like ThreadComposer or EditMessageComposer sharing a single Frame to scale UI libraries without fragile logic.

What is the compound components pattern with shared context in React?

Compound components with shared context enable flexible React composition without prop drilling. This pattern uses a generic context interface for dependency injection, letting parent and child components share state implicitly while remaining decoupled and reusable.

How to manage state in React using provider-based architecture?

Manage state using provider-based architecture by lifting state into centralized context providers. This centralizes state management and enables reuse across different UI framings, ensuring variant components access shared state without explicit prop passing.

Does this React composition approach work with React 19?

Yes, this React composition approach works with React 19 and includes specific API guidance. It leverages the use() hook for context consumption and recommends avoiding forwardRef where applicable to align with modern React 19 patterns.

When should I use explicit variants over boolean flags in component libraries?

Use explicit variants over boolean flags when scaling component libraries to prevent prop proliferation and reduce maintenance costs. Explicit variants like ForwardMessageComposer demonstrate clear usage without overlapping conditional logic, making components easier to test.

Why does prop drilling slow down React component development?

Prop drilling slows React component development by forcing manual state passing through unrelated intermediate layers. Provider-based state management and compound components with shared context eliminate this friction by centralizing state access and enabling direct consumption.