vercel-composition-patterns

Refactor React component APIs to use composition, compound components, and lifted state.

2|Updated Feb 12, 2024
One-click install
npx skills add https://github.com/adibfirman/dotfiles --skill vercel-composition-patterns-adibfirman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/adibfirman/dotfiles/tree/main/claude/.claude/skills/technical/react/composition-patterns
Command: npx skills add https://github.com/adibfirman/dotfiles --skill vercel-composition-patterns-adibfirman

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prevents React codebases from becoming unmaintainable when components grow lots of boolean props and hidden conditional rendering, making behavior hard to reason about and reuse.

Core Features & Use Cases

  • Compound component architecture: build component “parts” that share state via context instead of prop drilling or render-prop APIs.
  • Lift state into providers: move state management to provider boundaries so sibling or external UI can still read state and call actions.
  • Dependency-injected context contracts: define a consistent interface (state/actions/meta) so the same UI can work with different implementations.
  • Explicit variants over boolean modes: replace “one component with many flags” with dedicated variants that compose only what they need.
  • React 19 API alignment: use React 19 expectations such as use() (instead of useContext()) and treating ref as a regular prop.

Quick Start

Ask the AI to refactor your React component by removing boolean props, introducing a compound component with a context provider, and replacing conditional variants with explicit variant components for your specific use case.

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 stop prop drilling and boolean prop proliferation?

Refactor React components by replacing boolean props with explicit variant components and sharing state via context providers. This compound component architecture eliminates hidden conditional rendering and stops prop drilling, making component behavior easier to reason about and reuse.

What is the compound component pattern in React and when should I use it?

The compound component pattern builds component parts that share state via context instead of prop drilling. Use it when a component grows many boolean flags or hidden conditional rendering, making behavior hard to reason about and reuse in your React codebase.

How do I lift state into context providers for React UI libraries?

Lift state management into context provider boundaries so sibling or external UI can read state and call actions. Define a consistent state, actions, and meta interface contract so the same UI works with different implementations.

Does refactoring React component APIs require React 19 features?

React 19 alignment uses the use() hook instead of useContext() and treats ref as a regular prop. While the compound component pattern works in older versions, following React 19 requirements ensures your refactored component APIs meet modern expectations.

Why should I use explicit variants over boolean mode props in React?

Explicit variants replace one component with many flags by creating dedicated variant components that compose only what they need. This prevents hidden conditional rendering and makes component behavior explicit, avoiding the unmaintainable prop chaos of boolean modes.

What's the best way to compose children vs render props in React component architecture?

Prefer composing children over render props when refactoring React component APIs. Composing children alongside a dependency-injected context contract creates a cleaner, more maintainable interface than render-prop APIs, which often lead to hidden conditional rendering and prop chaos.