vercel-composition-patterns

Guide React component composition with compound components and context providers.

Updated Sep 7, 2025
One-click install
npx skills add https://github.com/BartekFo/my-dev-setup --skill vercel-composition-patterns-bartekfo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/BartekFo/my-dev-setup/tree/main/.agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/BartekFo/my-dev-setup --skill vercel-composition-patterns-bartekfo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the complexity of managing React component state and props, offering patterns to create more flexible, readable, and maintainable codebases.

Core Features & Use Cases

  • Component Architecture: Avoids boolean prop proliferation and promotes the use of compound components for better composition.
  • State Management: Guides on decoupling state logic from UI, defining generic context interfaces, and lifting state into providers.
  • Implementation Patterns: Recommends explicit component variants and preferring children composition over render props.
  • React 19 APIs: Covers new APIs like use() and handling refs as regular props.
  • Use Case: Refactor a large UserProfile component that has dozens of boolean flags into smaller, composable components like UserProfileHeader, UserProfileDetails, and UserProfileSettings, each managing its own state and logic.

Quick Start

Apply the vercel-composition-patterns skill to refactor the Composer component to use compound components instead of boolean props.

Frequently Asked Questions about vercel-composition-patterns

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

FAQPage Schema
How do I avoid boolean prop proliferation in React components?

Avoid boolean prop proliferation in React components by using compound components to split monolithic UIs into smaller, composable pieces like `UserProfileHeader` and `UserProfileDetails` that manage their own state and logic independently.

What is the best way to decouple state management logic from React component UI?

Decouple state management from React UI by lifting state into context providers and defining generic context interfaces. This pattern separates state logic from rendering, making components more flexible and maintainable across your codebase.

How do I refactor a monolithic React component into smaller composable parts?

Refactor a monolithic React component by breaking it down into smaller, composable parts using compound components. Replace complex boolean flags with explicit component variants and prefer children composition over render props for better architecture.

Does this React composition approach work with React 19 APIs?

Yes, the composition patterns support React 19 APIs, specifically covering how to use the new `use()` hook for context consumption and how to handle refs as regular props without needing forwardRef wrappers.

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

Use compound components instead of render props when you want to achieve better composition and readability. Preferring children composition over render props prevents prop drilling and creates more maintainable component architecture.

What are the limitations of using context providers for state management in React?

Context providers effectively decouple state from UI but require defining generic context interfaces to prevent unnecessary re-renders. Heavy reliance on context can complicate dependency injection if not carefully structured within your component architecture.