vercel-composition-patterns

Replace boolean props with React composition patterns and context providers.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Modern React components often balloon with boolean props leading to fragile conditional logic. This guide provides strategies to replace booleans with composition, compound components, and context-driven APIs to create flexible, maintainable UI.

Core Features & Use Cases

  • Compound components to share state via context and avoid prop drilling.
  • Lift state into provider components so UI stays UI-focused and reusable.
  • Create explicit variants (e.g., ThreadComposer, EditMessageComposer) to document behavior without boolean flags.
  • Apply patterns across refactors involving render props, context providers, and React 19 API changes.

Quick Start

Refactor a component library to use explicit variants and provider-based state management for scalable, maintainable UI.

Frequently Asked Questions about vercel-composition-patterns

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

FAQPage Schema
How do I replace boolean props in React components with composition patterns?

Replace boolean props in React components with explicit variants and compound components. This pattern removes fragile conditional logic by creating separate components like ThreadComposer or EditMessageComposer to document distinct behaviors without toggling flags.

How do I use context providers to avoid prop drilling in a React component library?

Use context providers to lift state management out of UI components. Compound components share this state via generic context interfaces, decoupling the UI from state logic and preventing prop drilling across deeply nested component trees.

What's the best way to scale a React UI with compound components and render props?

Scale React UIs by applying compound components and render props to create flexible, maintainable component libraries. These patterns allow components to share implicit state while keeping the UI focused and reusable.

Does React 19 change how context providers and composition patterns work?

React 19 introduces API changes that affect context providers and composition patterns. Refactoring strategies must account for these updates when applying compound components and lifting state into providers to ensure scalable component architectures.

When should I use explicit variants instead of boolean flags in React?

Use explicit variants instead of boolean flags when a React component needs to support multiple distinct behaviors. Defining separate components like EditMessageComposer clarifies intended usage and prevents the fragile conditional logic caused by boolean prop proliferation.

How do I decouple React UI components from state management logic?

Decouple React UI components from state management by lifting state into provider components. Define generic context interfaces to handle state, ensuring UI components remain focused on presentation and reusable across different application contexts.