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; if it fails, review reported errors, fix all type issues, and re-run until clean before proceeding
- Optimize - Apply memoization where needed, ensure accessibility; if new type errors are introduced, return to step 4
- Test - Write tests with React Testing Library; if any assertions fail, debug and fix before submitting
Reference Guide
Load detailed guidance based on context:
| Topic |
Reference |
Load When |
| Server Components |
references/server-components.md |
RSC patterns, Next.js App Router |
| React 19 |
references/react-19-features.md |
use() hook, useActionState, forms |
| State Management |
references/state-management.md |
Context, Zustand, Redux, TanStack |
| Hooks |
references/hooks-patterns.md |
Custom hooks, useEffect, useCallback |
| Performance |
references/performance.md |
memo, lazy, virtualization |
| Testing |
references/testing-react.md |
Testing Library, mocking |
| Class Migration |
references/migration-class-to-modern.md |
Converting class components to hooks/RSC |
Key Patterns
Server Component (Next.js App Router)
// app/users/page.tsx — Server Component, no "use client"
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;
// perform server action or fetch
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); // cleanup
}, []);
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
- Skip error boundaries in production
Output Templates
When implementing React features, provide:
- Component file with TypeScript types
- Test file if non-trivial logic
- Brief explanation of key decisions
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)
Documentation
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: MIT5metadata:6 source: https://skillmd.com/skills/jeffallan/react-expert7 author: https://github.com/Jeffallan8 version: "1.1.0"9 domain: frontend10 triggers: React, JSX, hooks, useState, useEffect, useContext, Server Components, React 19, Suspense, TanStack Query, Redux, Zustand, component, frontend11 role: specialist12 scope: implementation13 output-format: code14 related-skills: fullstack-guardian, playwright-expert, test-master15---1617# React Expert1819Senior React specialist with deep expertise in React 19, Server Components, and production-grade application architecture.2021## When to Use This Skill2223- Building new React components or features24- Implementing state management (local, Context, Redux, Zustand)25- Optimizing React performance26- Setting up React project architecture27- Working with React 19 Server Components28- Implementing forms with React 19 actions29- Data fetching patterns with TanStack Query or `use()`3031## Core Workflow32331. **Analyze requirements** - Identify component hierarchy, state needs, data flow342. **Choose patterns** - Select appropriate state management, data fetching approach353. **Implement** - Write TypeScript components with proper types364. **Validate** - Run `tsc --noEmit`; if it fails, review reported errors, fix all type issues, and re-run until clean before proceeding375. **Optimize** - Apply memoization where needed, ensure accessibility; if new type errors are introduced, return to step 4386. **Test** - Write tests with React Testing Library; if any assertions fail, debug and fix before submitting3940## Reference Guide4142Load detailed guidance based on context:4344| Topic | Reference | Load When |45|-------|-----------|-----------|46| Server Components | `references/server-components.md` | RSC patterns, Next.js App Router |47| React 19 | `references/react-19-features.md` | use() hook, useActionState, forms |48| State Management | `references/state-management.md` | Context, Zustand, Redux, TanStack |49| Hooks | `references/hooks-patterns.md` | Custom hooks, useEffect, useCallback |50| Performance | `references/performance.md` | memo, lazy, virtualization |51| Testing | `references/testing-react.md` | Testing Library, mocking |52| Class Migration | `references/migration-class-to-modern.md` | Converting class components to hooks/RSC |5354## Key Patterns5556### Server Component (Next.js App Router)57```tsx58// app/users/page.tsx — Server Component, no "use client"59import { db } from '@/lib/db';6061interface User {62 id: string;63 name: string;64}6566export default async function UsersPage() {67 const users: User[] = await db.user.findMany();6869 return (70 <ul>71 {users.map((user) => (72 <li key={user.id}>{user.name}</li>73 ))}74 </ul>75 );76}77```7879### React 19 Form with `useActionState`80```tsx81'use client';82import { useActionState } from 'react';8384async function submitForm(_prev: string, formData: FormData): Promise<string> {85 const name = formData.get('name') as string;86 // perform server action or fetch87 return `Hello, ${name}!`;88}8990export function GreetForm() {91 const [message, action, isPending] = useActionState(submitForm, '');9293 return (94 <form action={action}>95 <input name="name" required />96 <button type="submit" disabled={isPending}>97 {isPending ? 'Submitting…' : 'Submit'}98 </button>99 {message && <p>{message}</p>}100 </form>101 );102}103```104105### Custom Hook with Cleanup106```tsx107import { useState, useEffect } from 'react';108109function useWindowWidth(): number {110 const [width, setWidth] = useState(() => window.innerWidth);111112 useEffect(() => {113 const handler = () => setWidth(window.innerWidth);114 window.addEventListener('resize', handler);115 return () => window.removeEventListener('resize', handler); // cleanup116 }, []);117118 return width;119}120```121122## Constraints123124### MUST DO125- Use TypeScript with strict mode126- Implement error boundaries for graceful failures127- Use `key` props correctly (stable, unique identifiers)128- Clean up effects (return cleanup function)129- Use semantic HTML and ARIA for accessibility130- Memoize when passing callbacks/objects to memoized children131- Use Suspense boundaries for async operations132133### MUST NOT DO134- Mutate state directly135- Use array index as key for dynamic lists136- Create functions inside JSX (causes re-renders)137- Forget useEffect cleanup (memory leaks)138- Ignore React strict mode warnings139- Skip error boundaries in production140141## Output Templates142143When implementing React features, provide:1441. Component file with TypeScript types1452. Test file if non-trivial logic1463. Brief explanation of key decisions147148## Knowledge Reference149150React 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)151152[Documentation](https://jeffallan.github.io/claude-skills/skills/frontend/react-expert/)