vercel-composition-patterns

Refactor React 19 component APIs into compound components with lifted state.

41|6|Updated Nov 27, 2025
One-click install
npx skills add https://github.com/mralexsaavedra/spotiarr --skill vercel-composition-patterns-mralexsaavedra
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/mralexsaavedra/spotiarr/tree/main/skills/composition-patterns
Command: npx skills add https://github.com/mralexsaavedra/spotiarr --skill vercel-composition-patterns-mralexsaavedra

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves maintainability issues that arise when React components grow too configurable through boolean props, tangled state, or brittle component boundaries.

Core Features & Use Cases

  • Avoid boolean prop proliferation: prevents combinatorial UI states by replacing mode switches with compositional structure.
  • Use compound components with shared context: builds reusable component “parts” that cooperate through injected state, actions, and meta.
  • Lift and decouple state management: centralizes state logic in provider components so UI stays implementation-agnostic.
  • Prefer children over render props: improves readability and natural composition for static layout concerns.
  • Create explicit component variants: makes intent self-documenting by using separate variants (e.g., ThreadComposer vs. Composer with flags).
  • Align with React 19 API conventions: recommends using use() instead of useContext() and treating ref as a regular prop.

Quick Start

Tell the AI to audit your component API for boolean prop modes, then refactor it into explicit variants using compound components and lifted state via 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?

Replace boolean prop mode switches with explicit component variants and compositional structure. Create separate variants like ThreadComposer instead of flags, making component intent self-documenting while eliminating combinatorial UI states and unmaintainable branching.

What is the best way to decouple state management in reusable React components?

Lift and decouple state by centralizing state logic in context provider components. Define generic context interfaces for dependency injection so UI components remain implementation-agnostic while cooperating through injected state, actions, and meta.

When should I use compound components with context providers in React?

Use compound components with context providers when building reusable React parts that cooperate through shared state. This pattern suits React 19 codebases designing component APIs where multiple interactive parts share injected state, actions, and meta.

Should I prefer children over render props for React component composition?

Prefer children over render props for static layout structure to improve readability and natural composition. Use children when the component structure is static, reserving render props only when dynamic rendering logic is truly required.

Does this React component refactoring approach work with React 19 conventions?

Yes, the refactoring approach aligns with React 19 API conventions by recommending the use() hook instead of useContext() and treating ref as a regular prop. It supports modern ref and hook conventions for scalable component architecture.