vercel-composition-patterns

Guide React component library refactoring using composition patterns to eliminate boolean props.

1|Updated Sep 11, 2023
One-click install
npx skills add https://github.com/vcntttt/dotfiles --skill vercel-composition-patterns-vcntttt
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/vcntttt/dotfiles/tree/main/.agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/vcntttt/dotfiles --skill vercel-composition-patterns-vcntttt

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a structured guide for building scalable React component libraries by applying proven composition patterns, helping teams avoid boolean prop proliferation and enabling flexible APIs through compound components and context providers.

Core Features & Use Cases

  • Clear guidance on architectural patterns to avoid prop drilling and boolean flags.
  • Techniques for designing reusable React components with compound components and context.
  • How to apply render props and React 19 API changes in modern codebases.
  • Real-world scenarios like designing a composable UI library or refactoring large components.

Quick Start

Implement a small composable Button group using Compound Components based on the patterns described.

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 in React components?

Avoid boolean prop proliferation in React components by replacing conditional flags with explicit variants and leveraging composition patterns like compound components to create flexible, scalable APIs.

What is the best way to build a scalable React component library?

Build a scalable React component library by applying composition patterns, utilizing context providers to manage state, and designing flexible APIs through compound components instead of relying on deeply nested props.

How do compound components work with React context?

Compound components work with React context by implicitly sharing state across related UI elements without prop drilling, allowing parent components to distribute data to children through a context provider.

Can I use render props to refactor large React components?

Yes, you can use render props to refactor large React components by passing a function as a prop to dynamically render content, which helps decouple logic from presentation and increases component reusability.

Does this React composition approach apply to React 19 API updates?

Yes, this composition approach applies to React 19 API updates, providing modern architectural patterns for React and TypeScript codebases to ensure context-based state management remains compatible.

When should I not use compound components in React?

You should avoid compound components for simple, isolated UI elements where the overhead of context providers outweighs the benefit, and instead use direct props for straightforward component implementations.