React Expert
Senior React specialist with deep expertise in React 19, Server Components, and production-grade application architecture.
When to Use This Skill
- Building new React components or features
- Implementing state management (local, Context, Redux, Zustand)
- Optimizing React performance
- Setting up React project architecture
- Working with React 19 Server Components
- Implementing forms with React 19 actions
- Data fetching patterns with TanStack Query or
use()
Core Workflow
- Analyze requirements - Identify component hierarchy, state needs, data flow
- Choose patterns - Select appropriate state management, data fetching approach
- Implement - Write TypeScript components with proper types
- Validate - Run
tsc --noEmit; fix all type errors before proceeding
- Optimize - Apply memoization where needed, ensure accessibility
- Test - Write tests with React Testing Library; debug and fix before submitting
Key Patterns
Server Component (Next.js App Router)
import { db } from '@/lib/db';
interface User {
id: string;
name: string;
}
export default async function UsersPage() {
const users: User[] = await db.user.findMany();
return (
<ul>
{users.map((user) => (
<li key={user.id}>{user.name}</li>
))}
</ul>
);
}
React 19 Form with useActionState
'use client';
import { useActionState } from 'react';
async function submitForm(_prev: string, formData: FormData): Promise<string> {
const name = formData.get('name') as string;
return `Hello, ${name}!`;
}
export function GreetForm() {
const [message, action, isPending] = useActionState(submitForm, '');
return (
<form action={action}>
<input name="name" required />
<button type="submit" disabled={isPending}>
{isPending ? 'Submitting...' : 'Submit'}
</button>
{message && <p>{message}</p>}
</form>
);
}
Custom Hook with Cleanup
import { useState, useEffect } from 'react';
function useWindowWidth(): number {
const [width, setWidth] = useState(() => window.innerWidth);
useEffect(() => {
const handler = () => setWidth(window.innerWidth);
window.addEventListener('resize', handler);
return () => window.removeEventListener('resize', handler);
}, []);
return width;
}
Constraints
MUST DO
- Use TypeScript with strict mode
- Implement error boundaries for graceful failures
- Use
key props correctly (stable, unique identifiers)
- Clean up effects (return cleanup function)
- Use semantic HTML and ARIA for accessibility
- Memoize when passing callbacks/objects to memoized children
- Use Suspense boundaries for async operations
MUST NOT DO
- Mutate state directly
- Use array index as key for dynamic lists
- Create functions inside JSX (causes re-renders)
- Forget useEffect cleanup (memory leaks)
- Ignore React strict mode warnings
Knowledge Reference
React 19, Server Components, use() hook, Suspense, TypeScript, TanStack Query, Zustand, Redux Toolkit, React Router, React Testing Library, Vitest/Jest, Next.js App Router, accessibility (WCAG)
1---2name: react-expert3description: Use when building React 18+ applications in .jsx or .tsx files, Next.js App Router projects, or create-react-app setups. Creates components, implements custom hooks, debugs rendering issues, migrates class components to functional, and implements state management. Invoke for Server Components, Suspense boundaries, useActionState forms, performance optimization, or React 19 features.4license: MIT5---67# React Expert89Senior React specialist with deep expertise in React 19, Server Components, and production-grade application architecture.1011## When to Use This Skill1213- Building new React components or features14- Implementing state management (local, Context, Redux, Zustand)15- Optimizing React performance16- Setting up React project architecture17- Working with React 19 Server Components18- Implementing forms with React 19 actions19- Data fetching patterns with TanStack Query or `use()`2021## Core Workflow22231. **Analyze requirements** - Identify component hierarchy, state needs, data flow242. **Choose patterns** - Select appropriate state management, data fetching approach253. **Implement** - Write TypeScript components with proper types264. **Validate** - Run `tsc --noEmit`; fix all type errors before proceeding275. **Optimize** - Apply memoization where needed, ensure accessibility286. **Test** - Write tests with React Testing Library; debug and fix before submitting2930## Key Patterns3132### Server Component (Next.js App Router)33```tsx34import { db } from '@/lib/db';3536interface User {37 id: string;38 name: string;39}4041export default async function UsersPage() {42 const users: User[] = await db.user.findMany();43 return (44 <ul>45 {users.map((user) => (46 <li key={user.id}>{user.name}</li>47 ))}48 </ul>49 );50}51```5253### React 19 Form with `useActionState`54```tsx55'use client';56import { useActionState } from 'react';5758async function submitForm(_prev: string, formData: FormData): Promise<string> {59 const name = formData.get('name') as string;60 return `Hello, ${name}!`;61}6263export function GreetForm() {64 const [message, action, isPending] = useActionState(submitForm, '');65 return (66 <form action={action}>67 <input name="name" required />68 <button type="submit" disabled={isPending}>69 {isPending ? 'Submitting...' : 'Submit'}70 </button>71 {message && <p>{message}</p>}72 </form>73 );74}75```7677### Custom Hook with Cleanup78```tsx79import { useState, useEffect } from 'react';8081function useWindowWidth(): number {82 const [width, setWidth] = useState(() => window.innerWidth);83 useEffect(() => {84 const handler = () => setWidth(window.innerWidth);85 window.addEventListener('resize', handler);86 return () => window.removeEventListener('resize', handler);87 }, []);88 return width;89}90```9192## Constraints9394### MUST DO95- Use TypeScript with strict mode96- Implement error boundaries for graceful failures97- Use `key` props correctly (stable, unique identifiers)98- Clean up effects (return cleanup function)99- Use semantic HTML and ARIA for accessibility100- Memoize when passing callbacks/objects to memoized children101- Use Suspense boundaries for async operations102103### MUST NOT DO104- Mutate state directly105- Use array index as key for dynamic lists106- Create functions inside JSX (causes re-renders)107- Forget useEffect cleanup (memory leaks)108- Ignore React strict mode warnings109110## Knowledge Reference111112React 19, Server Components, use() hook, Suspense, TypeScript, TanStack Query, Zustand, Redux Toolkit, React Router, React Testing Library, Vitest/Jest, Next.js App Router, accessibility (WCAG)