vercel-composition-patterns

Guide React component architecture with compound components and state decoupling.

6|8|Updated May 9, 2024
One-click install
npx skills add https://github.com/GELLIFY/acme-app --skill vercel-composition-patterns-gellify
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/GELLIFY/acme-app/tree/main/.agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/GELLIFY/acme-app --skill vercel-composition-patterns-gellify

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill addresses the complexity of managing React component states and props, offering patterns to create more maintainable, flexible, and scalable codebases.

Core Features & Use Cases

  • Component Architecture: Avoids boolean prop proliferation and promotes the use of compound components for better composition.
  • State Management: Guides on decoupling state logic from UI and lifting state into provider components for easier sharing.
  • Implementation Patterns: Recommends explicit component variants and preferring children over render props for cleaner code.
  • React 19 APIs: Covers modern React features like use() and direct ref handling.
  • Use Case: Refactor a large, monolithic React component with many conditional rendering paths into a set of smaller, composable components using compound patterns and context providers.

Quick Start

Apply the vercel-composition-patterns skill to refactor the Composer component to use compound components instead of boolean props.

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?

To avoid boolean prop proliferation in React components, use explicit component variants and compound components. This pattern replaces conditional rendering logic with smaller, composable parts, improving code maintainability and preventing complex prop combinations.

What is the best way to refactor a monolithic React component with many conditional rendering paths?

The best way to refactor a monolithic React component is to apply composition patterns using compound components and context providers. This decouples state logic from the UI and replaces conditional rendering with explicit, composable component variants for better organization.

How do I decouple state management from UI in React?

Decouple state management from UI in React by lifting state into provider components. This pattern separates state logic from presentation, allowing nested components to access shared state directly through context without excessive prop drilling.

Does this React composition pattern support React 19 API changes?

Yes, these React composition patterns support React 19 API changes by incorporating modern features like the `use()` hook and direct ref handling. This ensures component architecture guidelines align with current React development practices.

Should I use render props or children for cleaner React component composition?

For cleaner React component composition, prefer using children over render props. This approach simplifies code organization and enhances readability by leveraging standard JSX nesting rather than injecting functions as props.