Skip to content

Building Components

Verified

React component building and composition best practices. Use when creating, reviewing, or refactoring React components. Covers component structure, props pat...

75 downloads
$ Add to .claude/skills/

About This Skill

# Building React Components

Best practices for building reusable, maintainable React components.

When to Apply

  • Reference these guidelines when:
  • Creating new React components
  • Reviewing component structure and API design
  • Refactoring components for better reusability
  • Implementing component composition patterns
  • Designing props interfaces

Core Principles

1. Single Responsibility Each component should do one thing well. Split large components into smaller, focused pieces.

2. Composition Over Inheritance Prefer composing components together rather than complex inheritance hierarchies.

```jsx // ✅ Good: Composition function Page() { return ( <Layout> <Header /> <Main> <Article /> </Main> <Footer /> </Layout> ); }

// ❌ Avoid: Deep nesting function Page() { return <LayoutWithHeaderAndFooter><MainContent /></LayoutWithHeaderAndFooter>; } ```

3. Props Design - Use TypeScript for props typing - Keep props interfaces simple and focused - Prefer many small props over few large objects - Use children prop for content composition

4. Component Structure ```tsx // ✅ Recommended structure import { FC } from 'react';

interface Props { title: string; children?: React.ReactNode; }

export const Card: FC<Props> = ({ title, children }) => { return ( <div className="card"> <h2>{title}</h2> {children} </div> ); }; ```

5. State Management - Keep state as close to where it's used as possible - Lift state up only when necessary - Consider custom hooks for reusable state logic

Common Patterns

Compound Components For flexible APIs like Select/Option, Tabs/TabList/Tab/TabPanel.

Render Props For sharing behavior while keeping rendering control.

Hooks For sharing stateful logic across components.

Related Skills - vercel-react-best-practices - next-best-practices - vercel-composition-patterns

Use Cases

  • Design reusable React component APIs with clean props interfaces and TypeScript typing
  • Refactor monolithic components into smaller, composable pieces following single responsibility
  • Review component structure for proper state management and composition patterns
  • Implement compound component patterns for flexible UIs like Select/Option or Tabs/TabPanel
  • Apply render props and custom hooks to share stateful logic across React components

Pros & Cons

Pros

  • +Covers the full spectrum from basic component structure to advanced patterns (compound, render props, hooks)
  • +Includes concrete code examples showing both good and bad patterns for quick reference
  • +Framework-agnostic principles (composition over inheritance, single responsibility) apply beyond React

Cons

  • -Guidelines only — does not generate or scaffold component code automatically
  • -Lacks coverage of performance optimization patterns like React.memo, useMemo, or code splitting
  • -No guidance on testing strategies for the component patterns it recommends

FAQ

What does Building Components do?
React component building and composition best practices. Use when creating, reviewing, or refactoring React components. Covers component structure, props pat...
What platforms support Building Components?
Building Components is available on Claude Code, OpenClaw.
What are the use cases for Building Components?
Design reusable React component APIs with clean props interfaces and TypeScript typing. Refactor monolithic components into smaller, composable pieces following single responsibility. Review component structure for proper state management and composition patterns.

100+ free AI tools

Writing, PDF, image, and developer tools — all in your browser.

Next Step

Use the skill detail page to evaluate fit and install steps. For a direct browser workflow, move into a focused tool route instead of staying in broader support surfaces.