/install building-components
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.
// ✅ Good: Composition
function Page() {
return (
\x3CLayout>
\x3CHeader />
\x3CMain>
\x3CArticle />
\x3C/Main>
\x3CFooter />
\x3C/Layout>
);
}
// ❌ Avoid: Deep nesting
function Page() {
return \x3CLayoutWithHeaderAndFooter>\x3CMainContent />\x3C/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\x3CProps> = ({ title, children }) => {
return (
\x3Cdiv className="card">
\x3Ch2>{title}\x3C/h2>
{children}
\x3C/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
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install building-components - After installation, invoke the skill by name or use
/building-components - Provide required inputs per the skill's parameter spec and get structured output
What is Building Components?
React component building and composition best practices. Use when creating, reviewing, or refactoring React components. Covers component structure, props pat... It is an AI Agent Skill for Claude Code / OpenClaw, with 336 downloads so far.
How do I install Building Components?
Run "/install building-components" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Building Components free?
Yes, Building Components is completely free (open-source). You can download, install and use it at no cost.
Which platforms does Building Components support?
Building Components is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Building Components?
It is built and maintained by Eave Luo (@eaveluo); the current version is v1.0.0.