π¦ ClawHub
Building Components
by @eaveluo
React component building and composition best practices. Use when creating, reviewing, or refactoring React components. Covers component structure, props pat...
TERMINAL
clawhub install building-componentsπ About This Skill
name: building-components description: React component building and composition best practices. Use when creating, reviewing, or refactoring React components. Covers component structure, props patterns, composition techniques, and reusability guidelines. license: MIT metadata: author: vercel version: "1.0.0"
Building React Components
Best practices for building reusable, maintainable React components.
When to Apply
Reference these guidelines when:
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.// β
Good: Composition
function Page() {
return (
);
}// β Avoid: Deep nesting
function Page() {
return ;
}
3. Props Design
4. Component Structure
// β
Recommended structure
import { FC } from 'react';interface Props {
title: string;
children?: React.ReactNode;
}
export const Card: FC = ({ title, children }) => {
return (
{title}
{children}
);
};