react-development
React 19+ with TypeScript — hooks, custom hooks, state management (useState/useReducer/useContext), React Query/SWR, Tailwind CSS, performance. Use when building React components, apps, or optimizing renders.
What this skill does
# React Development
> Optimized for React 19+, TypeScript 5.5+, React Testing Library 16+, and modern server-first app architectures.
Expert guidance for building high-quality React applications with React 19+, modern hooks, TypeScript, and best practices following official React documentation at https://react.dev.
- Leverage native parallel subagent dispatch and 200k+ context windows where available.
## Component Review Rubric Reference
Apply the shared [Component Review Rubric](../frontend-design/SKILL.md#component-review-rubric) before approving React components, then run the React-specific checks below.
## Anti-Patterns
- Fetching everything in client effects by default: Server-first data loading is usually simpler, faster, and easier to cache.
- Adding memoization before profiling: Manual optimizations can create stale-prop bugs and hide simpler design fixes.
- Skipping keyboard and accessible-name review: A component is not done if only pointer users can operate it reliably.
## Verification Protocol
Before claiming "skill applied successfully":
1. Pass/fail: The React Development guidance is tied to a concrete route, component, screen, or design artifact.
2. Pass/fail: Component states cover loading, empty, error, success, and responsive breakpoints where applicable.
3. Pass/fail: Accessibility, visual hierarchy, and interaction behavior are reviewed against the shared component rubric.
4. Pressure-test scenario: Review the component on a narrow mobile viewport, keyboard-only path, and slow-loading state.
5. Success metric: Zero generic UI approval; every approval cites rendered behavior or source evidence.
## Before and After Example
```tsx
// Before
'use client';
export function Dashboard() {
const [orders, setOrders] = useState<Order[]>([]);
useEffect(() => {
fetch('/api/orders').then((r) => r.json()).then(setOrders);
}, []);
return <OrdersTable orders={orders} />;
}
// After
export async function Dashboard() {
const orders = await getOrders();
return <OrdersTable orders={orders} />;
}
```
Lets the server boundary load data directly and keeps the client side focused on interaction, not bootstrapping.
## Activation Conditions
Use symptom -> action triggers: when one matches, apply this skill and verify with the protocol below.
**Core React Development:**
- Building React components with hooks and TypeScript
- Setting up React applications (Vite, Next.js, CRA)
- Working with React Router for navigation
- Implementing forms and user input handling
- Creating responsive layouts and component architecture
**State Management & Data:**
- Managing state (useState, useReducer, useContext)
- Implementing React Query or SWR for data fetching
- Building custom hooks for reusable stateful logic
- Creating Context providers for global state
- Implementing React 19 Server Components (if using Next.js)
**Component Patterns:**
- Creating reusable UI components with proper composition
- Building forms with React Hook Form and Zod validation
- Implementing modal dialogs and overlays
- Creating custom React hooks (useDebounce, useLocalStorage)
- Designing responsive variants for different screen sizes
**Performance & Quality:**
- Optimizing React app performance
- Implementing memoization (useMemo, useCallback)
- Code splitting and lazy loading
- Writing tests with React Testing Library
- Ensuring accessibility compliance (ARIA, keyboard nav)
## Part 1: React Fundamentals
### Project Structure
**Recommended Structure:**
```
src/
├── components/ # Reusable UI components
│ ├── ui/ # Primitives (Button, Input, Modal)
│ ├── forms/ # Form components
│ └── layout/ # Layout components
├── hooks/ # Custom hooks
├── contexts/ # Context providers
├── pages/ # Page components
├── lib/ # Utilities, API clients
├── types/ # TypeScript types
├── styles/ # Global styles
└── main.jsx # App entry point
```
### Component Architecture
#### Functional Components (React 19 Standard)
```typescript
interface ButtonProps {
variant: 'primary' | 'secondary' | 'danger';
size?: 'sm' | 'md' | 'lg';
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
children: React.ReactNode;
disabled?: boolean;
isLoading?: boolean;
}
export function Button({
variant = 'primary',
size = 'md',
onClick,
children,
disabled = false,
isLoading = false,
}: ButtonProps) {
const baseClasses = 'rounded-lg font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2';
const variantClasses = {
primary: 'bg-blue-600 hover:bg-blue-700 text-white focus:ring-blue-500',
secondary: 'bg-gray-100 hover:bg-gray-200 text-gray-900 focus:ring-gray-500',
danger: 'bg-red-600 hover:bg-red-700 text-white focus:ring-red-500',
};
const sizeClasses = {
sm: 'px-3 py-1.5 text-sm',
md: 'px-4 py-2 text-base',
lg: 'px-5 py-2.5 text-lg',
};
return (
<button
disabled={disabled || isLoading}
onClick={onClick}
className={`${baseClasses} ${variantClasses[variant]} ${sizeClasses[size]}`}
>
{isLoading ? 'Loading...' : children}
</button>
);
}
```
#### Generic Components
```typescript
interface ListProps<T> {
items: T[];
renderItem: (item: T, index: number) => React.ReactNode;
keyExtractor: (item: T) => string;
emptyMessage?: string;
}
function List<T>({ items, renderItem, keyExtractor, emptyMessage = 'No items' }: ListProps<T>) {
return (
<ul>
{items.length === 0 ? (
<li>{emptyMessage}</li>
) : (
items.map((item, index) => (
<li key={keyExtractor(item)}>
{renderItem(item, index)}
</li>
))
)}
</ul>
);
}
// Usage
<List
items={users}
renderItem={(user) => `${user.firstName} ${user.lastName}`}
keyExtractor={(user) => user.id}
/>
```
### Component Patterns
**Composition over Inheritance:**
```typescript
// ✅ GOOD - Component composition
function Card({ children }: { children: React.ReactNode }) {
return (
<div className="border rounded-lg p-4 shadow-sm">
{children}
</div>
);
}
function CardHeader({ children }: { children: React.ReactNode }) {
return (
<div className="font-bold text-lg mb-2 border-b pb-2">
{children}
</div>
);
}
function CardBody({ children }: { children: React.ReactNode }) {
return <div>{children}</div>;
}
// Usage
<Card>
<CardHeader>Title</CardHeader>
<CardBody>Content here</CardBody>
</Card>
// ❌ BAD - Inheritance or complex props
function Card({ renderHeader, renderBody, renderFooter }: { ... }) { ... }
```
**Presentational vs Container Components:**
```typescript
// Presentational - UI only, doesn't fetch data
interface UserCardProps {
user: User;
onStatusChange: (status: string) => void;
}
function UserCard({ user, onStatusChange }: UserCardProps) {
return (
<div>
<h3>{user.name}</h3>
<select value={user.status} onChange={(e) => onStatusChange(e.target.value)}>
<option value="active">Active</option>
<option value="inactive">Inactive</option>
</select>
</div>
);
}
// Container - Fetches data, passes to presentational
function UserContainer() {
const { data: user, mutate: updateStatus } = useUser(userId);
return user ? (
<UserCard user={user} onStatusChange={(status) => updateStatus({ status })} />
) : (
<LoadingSpinner />
);
}
```
---
## Part 2: Hooks Patterns
### Built-in Hooks Mastery
#### useState - For Local State
```typescript
// Simple state
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<span>{count}</span>
<button onClick={() => setCount(c => c + 1)}>Increment</button>
</div>
);
}
// Complex state - use useReducer instead
function Form() {
type FormState = {
name: string;
email: string;
submitted: boolean;
};
const [fRelated in Web Dev
generating-lwc-components
IncludedLightning Web Components with PICKLES methodology and 165-point scoring. Use this skill when the user creates or edits LWC components, builds wire service patterns, or writes Jest tests for LWC. TRIGGER when: user creates/edits LWC components, touches lwc/**/*.js, .html, .css, .js-meta.xml files, or asks about wire service, SLDS, or Jest LWC tests. DO NOT TRIGGER when: Apex classes (use generating-apex), Aura components, or Visualforce.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Set up queries with useQuery, mutations with useMutation, configure QueryClient caching strategies, implement optimistic updates, and handle infinite scroll with useInfiniteQuery. Use when: setting up data fetching in React projects, migrating from v4 to v5, or fixing object syntax required errors, query callbacks removed issues, cacheTime renamed to gcTime, isPending vs isLoading confusion, keepPreviousData removed problems.
document-processor-api
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
nutrient-document-processing
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Covers useMutationState, simplified optimistic updates, throwOnError, network mode (offline/PWA), and infiniteQueryOptions. Use when setting up data fetching, fixing v4→v5 migration errors (object syntax, gcTime, isPending, keepPreviousData), or debugging SSR/hydration issues with streaming server components.
accelint-nextjs-best-practices
IncludedNext.js performance optimization and best practices. Use when writing Next.js code (App Router or Pages Router); implementing Server Components, Server Actions, or API routes; optimizing RSC serialization, data fetching, or server-side rendering; reviewing Next.js code for performance issues; fixing authentication in Server Actions; or implementing Suspense boundaries, parallel data fetching, or request deduplication.