vercel-composition-patterns

Structure React components with compound components and context providers.

142|14|Updated Jan 14, 2020
One-click install
npx skills add https://github.com/marigold-ui/marigold --skill vercel-composition-patterns-marigold-ui
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/marigold-ui/marigold/tree/main/.agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/marigold-ui/marigold --skill vercel-composition-patterns-marigold-ui

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the complexity of building and maintaining React components by providing patterns to avoid prop proliferation and enable flexible composition.

Core Features & Use Cases

  • Compound Components: Structure complex components with shared context for flexible composition.
  • State Management Patterns: Decouple state logic from UI, define generic context interfaces, and lift state into providers.
  • Explicit Variants: Create distinct component variants instead of relying on numerous boolean props.
  • React 19 APIs: Leverage new APIs like use() and regular ref props for cleaner code.
  • Use Case: Refactor a monolithic Composer component with many boolean flags into a set of smaller, composable components like Composer.Input, Composer.Footer, and Composer.Submit, each managed by a context provider.

Quick Start

Apply the compound component pattern to refactor the Composer component by defining a shared context and composing its sub-components.

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 a monolithic React component with too many boolean props?

Refactor a monolithic React component by applying the compound component pattern to split it into smaller sub-components like Input and Footer, managed by a shared context provider. This avoids prop proliferation and enables flexible composition.

What is the compound component pattern in React?

The compound component pattern structures complex React components by defining a shared context. This allows flexible composition of sub-components, decoupling state logic from the UI and lifting it into context providers.

How do I manage state when building scalable React components?

Manage state in scalable React components by decoupling state logic from the UI. Define generic context interfaces and lift state into providers to ensure clean API design and maintainable component architecture.

Does this React composition approach support React 19 API changes?

Yes, this approach leverages React 19 APIs like the use() hook and regular ref props. These modern features enable cleaner code when structuring scalable React components using composition techniques.

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

Use explicit variants instead of numerous boolean props when you need distinct component variations. Creating explicit variants prevents prop proliferation and simplifies API design within complex React component architectures.

What's the best way to structure complex React components for flexible composition?

The best way to structure complex React components is using context providers and compound components. This composition technique manages component complexity and state while ensuring a clean, flexible API design.