composition-patterns

Implement scalable React UI with compound components and shared context.

24|5|Updated Nov 6, 2023
One-click install
npx skills add https://github.com/exactly/exa --skill composition-patterns-exactly
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: composition-patterns
Source: https://github.com/exactly/exa/tree/main/.agents/skills/composition-patterns
Command: npx skills add https://github.com/exactly/exa --skill composition-patterns-exactly

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

react composition patterns for building flexible, maintainable react components. avoid boolean prop proliferation by using compound components, lifting state, and composing internals.

Core Features & Use Cases

  • Compound components with shared context to structure complex UIs without prop drilling.
  • Explicit variants and frame-based composition to avoid boolean flags.
  • State lifting and provider-based architecture to enable cross-component coordination.
  • Guidance on when to apply these patterns in building component libraries and design systems.

Quick Start

Refactor a UI into a set of compound components with a shared provider to demonstrate the pattern.

Frequently Asked Questions about 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 by using compound components and explicit variant composition. This pattern replaces boolean flags with composable internal parts, enabling flexible and maintainable UI architecture without prop drilling.

What is the compound components pattern in React?

The compound components pattern in React structures complex UIs by grouping related components together with a shared context. This allows internal components to coordinate state implicitly without requiring manual prop drilling through every layer.

How do I share state across React UI components without prop drilling?

Share state across React UI components by lifting state to a shared provider and using context-driven state sharing. This provider-based architecture enables cross-component coordination, eliminating the need for prop drilling.

When should I use composition patterns for a React component library?

Use composition patterns for a React component library when building scalable design systems requiring reusable internal composition. Apply these patterns when you need explicit variant composition and context-driven state sharing across complex UIs.

How do I refactor a React UI into compound components?

Refactor a React UI into compound components by breaking it into a set of internal components sharing a single provider. This demonstrates the composition pattern by structuring the UI around a shared context rather than individual props.

What is the best way to structure complex React UIs for scalability?

The best way to structure complex React UIs for scalability is applying composition patterns. Using frame-based composition, explicit variants, and provider-based architecture ensures maintainable and reusable component structures in design systems.