vercel-composition-patterns

Refactor React component libraries using composition patterns and React 19 APIs.

Updated Oct 2, 2024
One-click install
npx skills add https://github.com/James-Gamboa/portfolio-james --skill vercel-composition-patterns-james-gamboa
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/James-Gamboa/portfolio-james/tree/main/.agents/skills/composition-patterns
Command: npx skills add https://github.com/James-Gamboa/portfolio-james --skill vercel-composition-patterns-james-gamboa

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Proliferation of boolean props and brittle, hard-to-maintain components is a common source of technical debt. This Skill demonstrates how to replace booleans with explicit, composable patterns that scale across teams and projects.

Core Features & Use Cases

  • Explicit variant components that document intent and reduce conditional logic.
  • Compound components with a shared context to enable flexible composition without prop drilling.
  • Provider-based state lifting to share state across disparate UI fragments and outside components.
  • React 19 API compatibility, including use() in place of useContext and avoiding forwardRef in typical usage.

Quick Start

Refactor an existing React component library to use explicit variant components, compound components with a shared provider, and context-based state management.

Frequently Asked Questions about vercel-composition-patterns

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

FAQPage Schema
How do I replace boolean props in React components with scalable patterns?

To replace boolean props in React components, apply composition patterns like building explicit variant components and using compound components with shared context to document intent and reduce conditional logic.

What is the best way to manage shared state across React components without prop drilling?

Managing shared state without prop drilling is best achieved through provider-based state lifting with context, which allows disparate UI fragments to share state explicitly across your component architecture.

How do compound components work with context providers in React 19?

Compound components with context providers work by sharing state implicitly across parent and child elements, leveraging React 19 APIs like the use() hook in place of useContext to enable flexible composition without prop drilling.

Do I need forwardRef when building React component libraries with composition patterns?

You do not need forwardRef when building React component libraries with modern composition patterns, as React 19 APIs allow you to avoid forwardRef in typical usage while safely scaling your reusable components.

When should I refactor React components to use explicit variant components?

You should refactor React components to use explicit variant components when boolean prop proliferation creates brittle, hard-to-maintain components, ensuring your UI components scale safely across teams and projects.