vercel-composition-patterns

Guide React component architecture with composition patterns and state management.

1|Updated Dec 21, 2024
One-click install
npx skills add https://github.com/SergeiGolos/wod-wiki --skill vercel-composition-patterns-sergeigolos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/SergeiGolos/wod-wiki/tree/main/.agent/skills/composition-patterns
Command: npx skills add https://github.com/SergeiGolos/wod-wiki --skill vercel-composition-patterns-sergeigolos

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes rules (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to advanced React composition patterns, helping developers build more flexible, maintainable, and scalable component architectures by avoiding common pitfalls like boolean prop proliferation.

Core Features & Use Cases

  • Component Architecture: Learn to structure components using compound components and avoid excessive boolean props.
  • State Management: Master lifting state into providers and defining generic context interfaces for dependency injection.
  • Implementation Patterns: Prefer composing children over render props and create explicit component variants.
  • React 19 APIs: Understand new APIs like use() and ref handling.
  • Use Case: Refactor a complex UI component with many conditional rendering paths into a set of well-defined, composable components that are easier to understand and extend.

Quick Start

Review the rules for component architecture and state management to refactor existing components.

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 by using composition patterns like compound components and explicit variants. This approach structures flexible, maintainable component architectures instead of relying on complex conditional rendering logic.

What is the best way to manage state with React context providers?

The best way to manage state with React context providers is lifting state into a provider and defining generic context interfaces. This dependency injection pattern separates state logic from presentation, ensuring scalable and maintainable component architectures.

How do I refactor a React component with many conditional rendering paths?

Refactor a React component with many conditional rendering paths by composing internals and preferring children over render props. Break the complex UI into well-defined, composable components that are easier to understand, extend, and maintain independently.

Does this React composition approach work with React 19 APIs?

Yes, this React composition approach works with React 19 APIs, specifically incorporating the new `use()` hook and updated ref handling. These APIs enhance state management and component implementation strategies for scalable architectures.

When should I prefer composing children over using render props in React?

Prefer composing children over render props in React when building scalable component architectures to reduce implementation complexity. Composing children enforces composition over configuration, yielding cleaner component structures and more predictable rendering outputs.