react-composition-patterns

Guide React component APIs using composition patterns like compound components and render props.

6|1|Updated Feb 27, 2026
One-click install
npx skills add https://github.com/RepairYourTech/cfsa-antigravity --skill react-composition-patterns-repairyourtech
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-composition-patterns
Source: https://github.com/RepairYourTech/cfsa-antigravity/tree/main/.agent/skill-library/stack/ui/react-composition-patterns
Command: npx skills add https://github.com/RepairYourTech/cfsa-antigravity --skill react-composition-patterns-repairyourtech

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to building robust, scalable, and maintainable React UIs by mastering various composition patterns, avoiding common pitfalls, and promoting reusable component architectures.

Core Features & Use Cases

  • Advanced Composition Techniques: Learn patterns like Compound Components, Render Props, Custom Hooks, Slot-Based Composition, and Polymorphic Components.
  • State Management Strategies: Understand how to lift state, manage controlled vs. uncontrolled components, and use Context effectively.
  • Form and Modal Patterns: Implement best practices for building complex forms and managing modal dialogs.
  • Use Case: When designing a new design system or refactoring a complex component library, use this guide to ensure your component APIs are flexible, intuitive, and prevent misuse.

Quick Start

Review the section on Compound Components to understand how to share state between related components.

Frequently Asked Questions about react-composition-patterns

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

FAQPage Schema
What is the best way to share state between related React components without prop drilling?

To build reusable React components, use composition patterns like render props, custom hooks, and explicit variants. These techniques allow you to create flexible, maintainable UI components with intuitive APIs that prevent misuse.

How do I manage controlled vs uncontrolled state in custom React hooks?

To manage controlled vs uncontrolled state in custom React hooks, implement patterns that support both internal state management and external state overrides. This approach provides flexibility for consumers of your reusable UI components.

When should I use slot-based composition or polymorphic components in a design system?

Use slot-based composition and polymorphic components in a design system when you need maximum rendering flexibility and API consistency. These React patterns allow components to accept dynamic structures while maintaining strict type safety.

Does this guide cover advanced patterns for modal management and complex forms in React?

Yes, this guide covers advanced patterns for modal management and complex forms in React. It provides best practices for managing modal dialogs and implementing robust form patterns, ensuring maintainable component architectures.

What React composition pattern should I use to prevent API misuse in a component library?

To prevent API misuse in a React component library, use explicit variants and compound components. These composition patterns enforce correct usage structurally, guiding consumers away from invalid states and ensuring robust component design.