vercel-composition-patterns

Refactor React components to use compound components, render props, and context providers.

7|Updated Apr 9, 2024
One-click install
npx skills add https://github.com/figueroaignacio/ai --skill vercel-composition-patterns-figueroaignacio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/figueroaignacio/ai/tree/main/.agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/figueroaignacio/ai --skill vercel-composition-patterns-figueroaignacio

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Refactor React components to avoid boolean prop proliferation and to enable scalable, reusable APIs through composition.

Core Features & Use Cases

  • Compound components with shared context to enable flexible composition without prop drilling.
  • Provider-based state management that decouples UI from implementation, enabling multiple backends (local, global, server-synced).
  • Explicit variant patterns (ThreadComposer, EditMessageComposer, ForwardMessageComposer) that document intent and reuse shared internals, improving maintainability.

Quick Start

Implement a ThreadComposer using a provider-based pattern to compose a Frame with Input and Submit, then reuse it to build Edit and Forward variants.

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 when scaling React components?

To avoid boolean prop proliferation in React components, apply robust composition patterns like compound components, render props, and context providers. These patterns decouple implementation details from the UI, enabling flexible and maintainable component APIs.

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

The compound components pattern in React uses shared context to enable flexible composition without prop drilling. It allows individual components to implicitly share state and logic, providing a clean API for building reusable UI libraries.

How do I refactor a React component to use provider-based state management?

Refactor React components to use provider-based state management by decoupling UI from implementation via context providers. This approach supports multiple backends like local, global, or server-synced state, improving scalability and reusability.

What is the best way to design explicit variants for reusable React APIs?

The best way to design explicit variants for reusable React APIs is to document intent using patterns like ThreadComposer or EditMessageComposer. These explicit variants reuse shared internals to improve maintainability while avoiding complex boolean logic.

Does React 19 introduce new APIs for composition and context providers?

Yes, React 19 introduces API guidance for composition, recommending the use() hook in place of useContext and supporting regular ref props. These updates streamline provider-based state management and component composition.