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: MIT5compatibility: opencode6metadata:7 source: https://skillmd.com/skills/belentani7/react-expert8 author: open-source9 version: "1.1.0"10 domain: frontend11 triggers: React, JSX, hooks, useState, useEffect, useContext, Server Components, React 19, Suspense, TanStack Query, Redux, Zustand, component, frontend12 role: specialist13 scope: implementation14 output-format: code15 related-skills: fullstack-guardian, playwright-expert, react-native-expert, shopify-expert, test-master16---1718# React Expert1920Senior React specialist with deep expertise in React 19, Server Components, and production-grade application architecture.2122## When to Use This Skill2324- Building new React components or features25- Implementing state management (local, Context, Redux, Zustand)26- Optimizing React performance27- Setting up React project architecture28- Working with React 19 Server Components29- Implementing forms with React 19 actions30- Data fetching patterns with TanStack Query or `use()`3132## Core Workflow33341. **Analyze requirements** - Identify component hierarchy, state needs, data flow352. **Choose patterns** - Select appropriate state management, data fetching approach363. **Implement** - Write TypeScript components with proper types374. **Validate** - Run `tsc --noEmit`; fix all type errors before proceeding385. **Optimize** - Apply memoization where needed, ensure accessibility396. **Test** - Write tests with React Testing Library; debug and fix before submitting4041## Key Patterns4243### Server Component (Next.js App Router)44```tsx45import { db } from '@/lib/db';4647interface User {48 id: string;49 name: string;50}5152export default async function UsersPage() {53 const users: User[] = await db.user.findMany();54 return (55 <ul>56 {users.map((user) => (57 <li key={user.id}>{user.name}</li>58 ))}59 </ul>60 );61}62```6364### React 19 Form with `useActionState`65```tsx66'use client';67import { useActionState } from 'react';6869async function submitForm(_prev: string, formData: FormData): Promise<string> {70 const name = formData.get('name') as string;71 return `Hello, ${name}!`;72}7374export function GreetForm() {75 const [message, action, isPending] = useActionState(submitForm, '');76 return (77 <form action={action}>78 <input name="name" required />79 <button type="submit" disabled={isPending}>80 {isPending ? 'Submitting...' : 'Submit'}81 </button>82 {message && <p>{message}</p>}83 </form>84 );85}86```8788### Custom Hook with Cleanup89```tsx90import { useState, useEffect } from 'react';9192function useWindowWidth(): number {93 const [width, setWidth] = useState(() => window.innerWidth);94 useEffect(() => {95 const handler = () => setWidth(window.innerWidth);96 window.addEventListener('resize', handler);97 return () => window.removeEventListener('resize', handler);98 }, []);99 return width;100}101```102103## Constraints104105### MUST DO106- Use TypeScript with strict mode107- Implement error boundaries for graceful failures108- Use `key` props correctly (stable, unique identifiers)109- Clean up effects (return cleanup function)110- Use semantic HTML and ARIA for accessibility111- Memoize when passing callbacks/objects to memoized children112- Use Suspense boundaries for async operations113114### MUST NOT DO115- Mutate state directly116- Use array index as key for dynamic lists117- Create functions inside JSX (causes re-renders)118- Forget useEffect cleanup (memory leaks)119- Ignore React strict mode warnings120121## Knowledge Reference122123React 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)