component-patterns

Implement React compound components, render props, and composition patterns with TypeScript.

2|2|Updated Nov 4, 2025
One-click install
npx skills add https://github.com/gizix/cc_projects --skill component-patterns-gizix
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: component-patterns
Source: https://github.com/gizix/cc_projects/tree/main/react-template/.claude/skills/component-patterns
Command: npx skills add https://github.com/gizix/cc_projects --skill component-patterns-gizix

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides developers in designing flexible, reusable, and maintainable React components by providing implementations of advanced component patterns, preventing rigid APIs and prop drilling.

Core Features & Use Cases

  • Compound Components: Build components with multiple related sub-components that share implicit state (e.g., Tabs, Accordion).
  • Composition Patterns: Create complex UIs by composing simple, focused components (e.g., Card with Card.Header, Card.Body).
  • Controlled vs Uncontrolled: Design form inputs that gracefully support both controlled (external state) and uncontrolled (internal state) modes.
  • Use Case: When building a new Dropdown component that needs to manage its own internal state but also allow external control, use this skill to implement the controlled/uncontrolled pattern, ensuring maximum flexibility.

Quick Start

Use the component-patterns skill to generate a Card component using the composition pattern, including Header, Body, and Footer sub-components.

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 that avoid prop drilling?

Compound components solve prop drilling by letting related sub-components share implicit state without passing props through every level. Use patterns like `Tabs` or `Accordion` where `Tabs.Panel` accesses state from its parent `Tabs` via React Context, eliminating intermediate prop chains.

What's the difference between controlled and uncontrolled React components?

Controlled components receive state from a parent prop and call callbacks to update it; uncontrolled components manage their own internal state. Implementing both patterns in a single component maximizes flexibility—users can either pass a value prop for external control or omit it for self-managed behavior.

How do I structure a React component with multiple related sub-components?

Composition patterns attach sub-components as properties on the parent, like `Card.Header`, `Card.Body`, and `Card.Footer`. This API lets users compose complex layouts from focused, reusable pieces while keeping the parent component clean and the structure declarative.

When should I use render props instead of component composition in React?

Render props give child components access to parent state and logic by accepting a function that returns JSX. Use this when you need granular control over what renders or when multiple children need the same stateful logic without creating nested wrapper components.

Can I use TypeScript with advanced React component patterns?

Yes. TypeScript typings work seamlessly with compound components, render props, and composition patterns. Properly typing Context, prop interfaces, and children render functions provides full type safety while building flexible, reusable component APIs.

Do I need React Context and hooks to implement component patterns?

React Context and hooks are core tools for advanced patterns. Context shares implicit state between compound components; hooks like `useContext` and `useState` power both controlled behavior and pattern logic with cleaner syntax than class-based alternatives.