vercel-composition-patterns

Refactor React component libraries by replacing boolean props with explicit variants.

12|1|Updated Apr 3, 2024
One-click install
npx skills add https://github.com/getsentry/webvitals.com --skill vercel-composition-patterns-getsentry
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/getsentry/webvitals.com/tree/main/.agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/getsentry/webvitals.com --skill vercel-composition-patterns-getsentry

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.

Core Features & Use Cases

  • Provides guidelines for refactoring components by replacing boolean props with explicit variants.
  • Encourages building reusable UI libraries through compound components, context providers, and dependency-injected state.
  • Applies to architecture reviews and design reviews across React projects, including migration to React 19.

Quick Start

Use the composition patterns to refactor a component library by replacing boolean props with explicit variants and introducing shared context providers.

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?

To fix boolean prop proliferation in React components, replace boolean flags with explicit variants and refactor the component structure using compound components to isolate concerns and restore predictable rendering behavior.

What is the best way to scale a React component library API?

Scaling a React component library API requires applying composition patterns, specifically utilizing context providers to lift shared state and compound components to expose flexible, dependency-injected component structures.

How do context providers improve React composition patterns?

Context providers improve React composition patterns by lifting shared state out of individual components into a centralized interface, exposing state, actions, and metadata to nested compound components without prop drilling.

Does this React composition approach support React 19 API changes?

Yes, these React composition patterns explicitly accommodate React 19 API changes, ensuring that refactored component libraries utilizing context providers and compound components remain compatible with the latest React 19 architecture updates.

When should I use compound components instead of render props in React?

Use compound components to build explicit, reusable UI structures with shared context, whereas render props are better suited for injecting custom rendering logic within those shared context boundaries during component refactoring.

Why do explicit variants solve React component scaling issues?

Explicit variants solve React component scaling issues by replacing ambiguous boolean props with distinct component states, preventing conflicting prop combinations and simplifying the shared context interface logic across the UI codebase.