vercel-composition-patterns

Guide React composition patterns using compound components, render props, and context providers.

Updated Mar 28, 2025
One-click install
npx skills add https://github.com/gileck/app-template-ai --skill vercel-composition-patterns-gileck
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/gileck/app-template-ai/tree/main/.ai/skills/template/vercel-composition-patterns
Command: npx skills add https://github.com/gileck/app-template-ai --skill vercel-composition-patterns-gileck

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps teams avoid the pitfalls of boolean prop proliferation in React by teaching composition-based patterns that lead to more flexible, readable, and maintainable components.

Core Features & Use Cases

  • Explicit component variants: replace mode flags with dedicated components like ThreadComposer, EditMessageComposer, and ForwardMessageComposer.
  • Compound components with shared context: build UI parts that assemble around a single provider, enabling state sharing without prop drilling.
  • State lifting and dependency injection: move state into providers so UI components remain UI-focused, while logic lives in providers.
  • Use cases: refactoring component libraries, designing reusable APIs, and organizing large UI architectures that benefit from clear composition boundaries.

Quick Start

Use this skill as a reference when restructuring a React component library to eliminate boolean props and enable scalable composition.

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?

To avoid boolean prop proliferation in React components, replace mode flags with explicit component variants like ThreadComposer or EditMessageComposer, creating dedicated components for each UI state instead of overloading a single component with conditional logic.

What is the compound component pattern with shared context in React?

The compound component pattern with shared context in React assembles UI parts around a single provider, enabling state sharing across child components without prop drilling. This keeps components flexible while maintaining clear composition boundaries.

How do I refactor a React component library for better composition?

Refactor a React component library for better composition by replacing boolean flags with explicit variants, lifting state into context providers, and applying compound component patterns using standard React and TypeScript without requiring extra tooling.

When should I use render props and provider patterns in React?

Use render props and provider patterns in React when building reusable APIs, refactoring large UI architectures, or needing dependency injection. They keep UI components focused on presentation while logic lives in providers, ensuring scalable composition boundaries.

Can I implement React composition patterns without extra libraries?

You can implement React composition patterns without extra libraries using standard React and TypeScript. The patterns rely on built-in context providers, explicit component variants, and state lifting techniques that require no additional tooling or dependencies.

What are the limitations of compound components in React?

Compound components in React can introduce context complexity in deeply nested trees and may require careful provider lifting. When components rely heavily on shared context, debugging state flow becomes harder, making them less suitable for simple, isolated UI elements.