
React Component Architecture
- 607 installs
- 305 repo stars
- Updated March 4, 2026
- aj-geddes/useful-ai-prompts
react-component-architecture is a Claude Code skill that teaches reusable React and TypeScript component patterns, hooks, and composition rules for developers building maintainable UI layers and component libraries.
About
react-component-architecture is a Claude Code skill from aj-geddes/useful-ai-prompts that codifies scalable React UI design with functional components, hooks, composition, and TypeScript type safety. The skill includes reference guides, quick-start patterns, and best practices for component library design and large-scale React applications. Developers reach for react-component-architecture when scaffolding a new UI layer, refactoring monolithic components, or establishing team conventions for props, state, and composition. It focuses on maintainable structure rather than visual styling, making it a fit during greenfield builds and ongoing refactors alike.
- Functional components with TypeScript props for variants, sizes, and disabled states
- Composition patterns and custom hooks for scalable libraries and large apps
- Quick-start Button example with variant and size style maps
- Reference guides for performance optimization and reusable UI patterns
- Explicit When to Use list: libraries, large-scale apps, hooks, and perf work
React Component Architecture by the numbers
- 607 all-time installs (skills.sh)
- Ranked #562 of 2,245 Frontend Development skills by installs in the Skillselion catalog
- Security screen: LOW risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill react-component-architectureAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 607 |
|---|---|
| repo stars | ★ 305 |
| Security audit | 3 / 3 scanners passed |
| Last updated | March 4, 2026 |
| Repository | aj-geddes/useful-ai-prompts ↗ |
How do you structure scalable React components with TypeScript?
Install this when you want reusable React + TypeScript component patterns, hooks, and composition rules for a maintainable UI layer.
Who is it for?
Frontend developers building React and TypeScript component libraries or large applications that need consistent composition and hook patterns.
Skip if: Teams using Vue, Svelte, or Angular, or projects needing only CSS and visual design guidance should skip react-component-architecture.
When should I use this skill?
A developer asks to design React components, establish a component library, or refactor a React UI layer with hooks and TypeScript.
What you get
Typed React component hierarchy with hooks, composition patterns, and documented UI architecture conventions.
- Component architecture conventions
- Typed React component patterns
Files
React Component Architecture
Table of Contents
Overview
Build scalable, maintainable React components using modern patterns including functional components, hooks, composition, and TypeScript for type safety.
When to Use
- Component library design
- Large-scale React applications
- Reusable UI patterns
- Custom hooks development
- Performance optimization
Quick Start
Minimal working example:
// Button.tsx
import React, { useState, useCallback } from 'react';
interface ButtonProps {
variant?: 'primary' | 'secondary' | 'danger';
size?: 'sm' | 'md' | 'lg';
disabled?: boolean;
onClick?: () => void;
children: React.ReactNode;
}
export const Button: React.FC<ButtonProps> = ({
variant = 'primary',
size = 'md',
disabled = false,
onClick,
children
}) => {
const variantStyles = {
primary: 'bg-blue-500 hover:bg-blue-600',
secondary: 'bg-gray-500 hover:bg-gray-600',
danger: 'bg-red-500 hover:bg-red-600'
};
const sizeStyles = {
// ... (see reference guides for full implementation)Reference Guides
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Functional Component with Hooks | Functional Component with Hooks |
| Custom Hooks Pattern | Custom Hooks Pattern |
| Composition Pattern | Composition Pattern |
| Higher-Order Component (HOC) | Higher-Order Component (HOC) |
| Render Props Pattern | Render Props Pattern |
Best Practices
✅ DO
- Follow established patterns and conventions
- Write clean, maintainable code
- Add appropriate documentation
- Test thoroughly before deploying
❌ DON'T
- Skip testing or validation
- Ignore error handling
- Hard-code configuration values
Composition Pattern
Composition Pattern
// Card.tsx
interface CardProps {
children: React.ReactNode;
className?: string;
}
const Card: React.FC<CardProps> = ({ children, className = '' }) => (
<div className={`border rounded p-4 ${className}`}>{children}</div>
);
const CardHeader: React.FC<CardProps> = ({ children }) => (
<div className="border-b pb-2 mb-3 font-bold">{children}</div>
);
const CardBody: React.FC<CardProps> = ({ children }) => (
<div className="py-2">{children}</div>
);
const CardFooter: React.FC<CardProps> = ({ children }) => (
<div className="border-t pt-2 mt-3">{children}</div>
);
// Compound component
export { Card };
Card.Header = CardHeader;
Card.Body = CardBody;
Card.Footer = CardFooter;
// Usage
<Card>
<Card.Header>Title</Card.Header>
<Card.Body>Content</Card.Body>
<Card.Footer>Actions</Card.Footer>
</Card>Custom Hooks Pattern
Custom Hooks Pattern
// useFormInput.ts
import { useState, useCallback } from 'react';
interface UseFormInputOptions {
initialValue?: string;
validator?: (value: string) => string | null;
}
export const useFormInput = (options: UseFormInputOptions = {}) => {
const [value, setValue] = useState(options.initialValue || '');
const [error, setError] = useState<string | null>(null);
const validate = useCallback(() => {
if (options.validator) {
const validationError = options.validator(value);
setError(validationError);
return !validationError;
}
return true;
}, [value, options.validator]);
const reset = useCallback(() => {
setValue(options.initialValue || '');
setError(null);
}, [options.initialValue]);
return {
value,
setValue,
error,
validate,
reset,
bind: {
value,
onChange: (e: React.ChangeEvent<HTMLInputElement>) => setValue(e.target.value)
}
};
};
// Usage
const MyForm: React.FC = () => {
const email = useFormInput({
validator: (v) => !v.includes('@') ? 'Invalid email' : null
});
return (
<div>
<input {...email.bind} />
{email.error && <span className="text-red-500">{email.error}</span>}
</div>
);
};Functional Component with Hooks
Functional Component with Hooks
// Button.tsx
import React, { useState, useCallback } from 'react';
interface ButtonProps {
variant?: 'primary' | 'secondary' | 'danger';
size?: 'sm' | 'md' | 'lg';
disabled?: boolean;
onClick?: () => void;
children: React.ReactNode;
}
export const Button: React.FC<ButtonProps> = ({
variant = 'primary',
size = 'md',
disabled = false,
onClick,
children
}) => {
const variantStyles = {
primary: 'bg-blue-500 hover:bg-blue-600',
secondary: 'bg-gray-500 hover:bg-gray-600',
danger: 'bg-red-500 hover:bg-red-600'
};
const sizeStyles = {
sm: 'px-2 py-1 text-sm',
md: 'px-4 py-2 text-base',
lg: 'px-6 py-3 text-lg'
};
return (
<button
className={`${variantStyles[variant]} ${sizeStyles[size]} text-white rounded disabled:opacity-50`}
disabled={disabled}
onClick={onClick}
>
{children}
</button>
);
};Higher-Order Component (HOC)
Higher-Order Component (HOC)
// withLoader.tsx
interface WithLoaderProps {
isLoading: boolean;
error?: Error | null;
}
function withLoader<P extends object>(
Component: React.ComponentType<P>
): React.FC<P & WithLoaderProps> {
return ({ isLoading, error, ...props }: P & WithLoaderProps) => {
if (isLoading) return <div>Loading...</div>;
if (error) return <div className="text-red-500">{error.message}</div>;
return <Component {...(props as P)} />;
};
}
// Usage
const UserList: React.FC<{ users: User[] }> = ({ users }) => (
<ul>{users.map(u => <li key={u.id}>{u.name}</li>)}</ul>
);
export const LoadingUserList = withLoader(UserList);Render Props Pattern
Render Props Pattern
// DataFetcher.tsx
interface DataFetcherProps<T> {
url: string;
children: (data: T | null, loading: boolean, error: Error | null) => React.ReactNode;
}
export const DataFetcher = <T,>({ url, children }: DataFetcherProps<T>) => {
const [data, setData] = React.useState<T | null>(null);
const [loading, setLoading] = React.useState(true);
const [error, setError] = React.useState<Error | null>(null);
React.useEffect(() => {
fetch(url)
.then(r => r.json())
.then(setData)
.catch(setError)
.finally(() => setLoading(false));
}, [url]);
return <>{children(data, loading, error)}</>;
};
// Usage
<DataFetcher<User[]> url="/api/users">
{(users, loading, error) => (
<>{loading ? <p>Loading...</p> : users?.map(u => <p key={u.id}>{u.name}</p>)}</>
)}
</DataFetcher>// Component: [Name]
// TODO: Customize for your framework (React, Vue, Svelte, etc.)
import React from 'react';
interface Props {
// TODO: Define props
}
export function ComponentName({ }: Props) {
// TODO: Add state and effects
return (
<div>
{/* TODO: Add component markup */}
</div>
);
}
Related skills
FAQ
What React patterns does react-component-architecture cover?
react-component-architecture covers functional components, hooks, composition patterns, and TypeScript type safety with reference guides and best practices for component libraries and large React applications.
When should developers use react-component-architecture?
react-component-architecture fits component library design, large-scale React application structure, and refactors where reusable typed components, hooks, and composition rules need consistent team conventions.
Is React Component Architecture safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.