component-patterns

Explain advanced React component composition patterns with TypeScript examples.

2|1|Updated Nov 13, 2025
One-click install
npx skills add https://github.com/MolcajeteAI/plugin --skill component-patterns-molcajeteai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: component-patterns
Source: https://github.com/MolcajeteAI/plugin/tree/main/deprecated/tech-stacks/js/react/skills/component-patterns
Command: npx skills add https://github.com/MolcajeteAI/plugin --skill component-patterns-molcajeteai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the challenge of building reusable, flexible, and maintainable React components by demonstrating various advanced composition patterns.

Core Features & Use Cases

  • Composition Patterns: Explains and provides examples for Compound Components, Render Props, Slots, Polymorphic Components, and Controlled/Uncontrolled patterns.
  • Best Practices: Outlines key principles for effective component design, including TypeScript usage, prop forwarding, and single responsibility.
  • Use Case: When developing a design system or a complex UI library, use this skill to understand and implement patterns that ensure components are easy to use, extend, and integrate.

Quick Start

Use the component-patterns skill to generate a TypeScript example for a compound component in React.

Frequently Asked Questions about component-patterns

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

FAQPage Schema
How do I build reusable React components using composition patterns?

React compound components allow related UI elements to share state implicitly without prop drilling. They use React Context to manage internal state distribution, ensuring flexible composition while maintaining strict TypeScript type safety for individual child components.

What is the difference between controlled and uncontrolled patterns in React UI development?

Controlled React components manage state externally via props, while uncontrolled components maintain internal state. TypeScript enforces strict type safety for both approaches, ensuring predictable data flow when building maintainable UI component libraries.

How do I create polymorphic components in React with TypeScript?

Polymorphic React components dynamically render as different HTML elements while maintaining strict TypeScript type safety. TypeScript generics validate prop forwarding and attributes, ensuring accurate type checking based on the rendered element type in UI libraries.

When should I use render props versus slots for React component composition?

Use render props in React to share complex rendering logic and state explicitly between components. Use slots to inject UI elements into predefined layout positions, ensuring clear separation of concerns and maintainable component composition.

Can I use these React component patterns for building a design system?

Yes, these React component patterns are specifically designed for building a design system or complex UI library. They ensure components are reusable, maintainable, and easy to integrate by leveraging TypeScript and composition over configuration principles.

Why should I avoid configuration-heavy props when developing a React component library?

Avoiding configuration-heavy props prevents React components from becoming rigid and difficult to maintain. Prioritizing composition over configuration allows developers to nest and arrange UI elements dynamically, ensuring maximum flexibility for component library consumers.