building-components
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.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/eaveluo/building-componentsBuilding 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.
// ✅ 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
// ✅ 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
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-eaveluo-building-components": {
"enabled": true,
"auto_update": true
}
}
}Related Skills
stock-monitor-pro
专业级智能股票监控预警系统 V2.1。支持收盘日报自动生成、反爬虫优化(Session级UA、多数据源冗余)、成本百分比预警、均线金叉死叉、RSI超买超卖、成交量异动监控、智能错误提醒。符合中国投资者习惯(红涨绿跌)。Use when user needs stock market monitoring, price alerts, daily reports, or automated trading notifications for A-shares and ETFs.
claude-code-setup
Setup production-grade .claude/ AI collaboration layer for projects. Use when an agent starts using Claude Code for development, enters a new project directory, or when user mentions "Claude Code", ".claude config", "AI collaboration layer", or "project standards".