vercel-composition-patterns

Refactor React component libraries using composition patterns and context providers.

30|1|Updated Feb 19, 2022
One-click install
npx skills add https://github.com/princejoogie/dotfiles --skill vercel-composition-patterns-princejoogie
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/princejoogie/dotfiles/tree/main/opencode/.config/opencode/skills/vercel-composition-patterns
Command: npx skills add https://github.com/princejoogie/dotfiles --skill vercel-composition-patterns-princejoogie

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Designing scalable React components often leads to boolean prop proliferation and tangled UI logic. This skill provides structured patterns to build flexible component libraries via composition, compound components, and context providers, enabling cleaner architectures and reusable APIs.

Core Features & Use Cases

  • Create explicit component variants (e.g., ThreadComposer, EditMessageComposer, ForwardMessageComposer) to replace multi-flag components and improve readability.
  • Implement compound components with a shared context to avoid prop drilling and enable flexible, reusable UI composition.
  • Leverage render props and context providers to compose UI from modular parts while keeping state management isolated and swapable.
  • Update to React 19 APIs (use() in place of useContext) to simplify context usage and reduce boilerplate in modern React apps.

Quick Start

Create a ThreadComposer using explicit variants for channel, edit, and forward messages.

Frequently Asked Questions about vercel-composition-patterns

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

FAQPage Schema
How do I scale React components without using fragile boolean props?

To scale React components without boolean props, replace multi-flag components with explicit variants like ThreadComposer, compound components, and context providers. This composition pattern enforces a provider-based architecture to improve UI flexibility and maintain reusable APIs across projects.

What is the compound components pattern in React and when should I use it?

The compound components pattern in React builds flexible UIs by composing modular parts that share a single context. Use this pattern to avoid prop drilling, keep state management isolated, and enable reusable component library APIs across projects.

How do I refactor a React component library to use explicit variants?

Refactor a React component library by replacing boolean prop configurations with explicit variant components such as ThreadComposer or EditMessageComposer. Use composition patterns and generic context interfaces to isolate state and improve code readability.

Can I use React 19 APIs like use() for context access in composition patterns?

Yes, you can use React 19 APIs like use() in place of useContext to simplify context access. Applying use() within context providers reduces boilerplate and streamlines state management when building compound components.

How do render props and context providers improve React UI flexibility?

Render props and context providers improve React UI flexibility by allowing you to compose UI from modular parts while keeping state management isolated and swappable. This architecture enforces explicit variants and enables reusable APIs.

When should I not use compound components in React?

Avoid compound components in React when explicit variants or simpler boolean props suffice for your use case. Composition patterns with shared context add architectural overhead that may not benefit small, static UIs without complex state management needs.