react-components
$
npx mdskill add langchain-ai/skills-benchmarks/react-componentsGenerate robust, modern React components using functional patterns, hooks, and TypeScript.
- Build complex UI elements requiring state management and side effects.
- Utilizes standard React APIs like useState, useEffect, and useCallback.
- Determines component structure based on required data fetching and user interactions.
- Outputs complete, type-safe, and reusable JSX code blocks for integration.
SKILL.md
.github/skills/react-componentsView on GitHub ↗
---
name: react-components
description: Modern React component patterns with hooks and TypeScript
---
# React Component Patterns
Build maintainable React components using modern patterns.
## Functional Components with Hooks
Always prefer functional components over class components:
```tsx
import { useState, useEffect, useCallback } from 'react';
interface UserProps {
userId: string;
onUpdate?: (user: User) => void;
}
export function UserProfile({ userId, onUpdate }: UserProps) {
const [user, setUser] = useState<User | null>(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
fetchUser(userId).then(setUser).finally(() => setLoading(false));
}, [userId]);
const handleSave = useCallback(async (data: UserData) => {
const updated = await updateUser(userId, data);
setUser(updated);
onUpdate?.(updated);
}, [userId, onUpdate]);
if (loading) return <Skeleton />;
if (!user) return <NotFound />;
return <UserForm user={user} onSave={handleSave} />;
}
```
## Custom Hooks
Extract reusable logic into custom hooks:
```tsx
function useAsync<T>(asyncFn: () => Promise<T>, deps: any[]) {
const [state, setState] = useState<AsyncState<T>>({
loading: true,
error: null,
data: null,
});
useEffect(() => {
setState(s => ({ ...s, loading: true }));
asyncFn()
.then(data => setState({ loading: false, error: null, data }))
.catch(error => setState({ loading: false, error, data: null }));
}, deps);
return state;
}
```
## Component Composition
Use composition over prop drilling:
```tsx
<Card>
<Card.Header>Title</Card.Header>
<Card.Body>{content}</Card.Body>
<Card.Footer>
<Button>Action</Button>
</Card.Footer>
</Card>
```
More from langchain-ai/skills-benchmarks
- api-docsOpenAPI documentation and REST API design patterns
- framework-selection"INVOKE THIS SKILL at the START of any LangChain/LangGraph/Deep Agents project, before writing any agent code. Determines which framework layer is right for the task: LangChain, LangGraph, Deep Agents, or a combination. Must be consulted before other agent skills."
- langchain-oss-primer"ALWAYS START HERE for any LangChain, Deep Agents, or LangGraph agent building project. Required starting point before choosing other skills or writing any code. Covers framework selection (LangChain vs LangGraph vs Deep Agents), agent archetypes, dependency setup, and which skills to load next based on your decisions."
- langsmith-dataset"INVOKE THIS SKILL when creating evaluation datasets, uploading datasets to LangSmith, or managing existing datasets. Covers dataset types (final_response, single_step, trajectory, RAG), CLI management commands, SDK-based creation, and example management. Uses the langsmith CLI tool."
- langsmith-evaluatorINVOKE THIS SKILL when building evaluation pipelines for LangSmith. Covers three core components: (1) Creating Evaluators - LLM-as-Judge, custom code; (2) Defining Run Functions - how to capture outputs and trajectories from your agent; (3) Running Evaluations - locally with evaluate() or auto-run via LangSmith. Uses the langsmith CLI tool.