vercel-composition-patterns

Refactor React components with boolean props into compound components using context providers.

Updated Jul 2, 2025
One-click install
npx skills add https://github.com/janpeterd/dotfiles --skill vercel-composition-patterns-janpeterd
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/janpeterd/dotfiles/tree/main/dot_agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/janpeterd/dotfiles --skill vercel-composition-patterns-janpeterd

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It resolves React component maintainability issues caused by boolean prop proliferation and tangled state/UI coupling, replacing them with composable, explicit architectures that scale reliably.

Core Features & Use Cases

  • Avoid boolean prop proliferation by replacing conditional modes with explicit composed variants.
  • Use compound components with shared context so subcomponents receive state/actions via a provider instead of prop drilling.
  • Lift state into provider components to enable sibling or external UI elements to read and trigger actions safely.
  • Define generic context interfaces (state, actions, meta) so UI remains independent from the underlying state implementation.
  • Apply React 19+ API guidance by preferring use() over useContext() and using ref as a regular prop rather than forwardRef.

Quick Start

Ask an AI to refactor a React component with many boolean props into explicit compound variants using a context provider that lifts state and actions, following the React 19+ rules included in this skill.

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 with too many boolean props?

Refactor React components by replacing boolean prop proliferation with explicit composition patterns. Use compound components and context providers to decouple state from UI, creating composable variants that scale reliably in medium-to-large codebases.

What is the best way to use compound components with shared context in React?

Use compound components with shared context by lifting state into provider components. This allows subcomponents to receive state and actions via a provider instead of prop drilling, keeping UI elements independent from the underlying state implementation.

How do I structure context interfaces to separate state from actions in React?

Structure context interfaces by defining generic contracts that separate state, actions, and meta. This keeps your UI independent from the state implementation and enables sibling or external UI elements to read and trigger actions safely.

Does this React composition pattern require React 19?

This composition pattern applies React 19+ API guidance, preferring the use() hook over useContext() and treating ref as a regular prop rather than using forwardRef. It is designed for React 19+ usage rules.

When should I avoid boolean props in React component architecture?

Avoid boolean props in React component architecture when conditional modes cause unmaintainable logic and tangled state/UI coupling. Shift to explicit composed variants to resolve maintainability issues across medium-to-large codebases.