Provides React best practices for functional components, hooks, state management, performance, and accessibility. Use when writing or reviewing React components, hooks, or state logic.
Ships in recipe-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Best practices for React development: functional components, hooks, state management, performance, and accessibility.
Component.tsx, Component.test.tsx, and Component.module.css togetherComponentNameProps// Good
interface UserCardProps {
user: User;
onSelect: (id: string) => void;
variant?: "compact" | "full";
}
export function UserCard({ user, onSelect, variant = "full" }: UserCardProps) {
return ( /* ... */ );
}
// Bad -- default export, inline props, class component
export default class UserCard extends React.Component<{user: any}> { /* ... */ }
use -- useAuth, useDebounce, useLocalStorage// Simple: return tuple
function useToggle(initial = false): [boolean, () => void] {
const [value, setValue] = useState(initial);
const toggle = useCallback(() => setValue((v) => !v), []);
return [value, toggle];
}
// Complex: return object
function useApi<T>(url: string) {
const [data, setData] = useState<T | null>(null);
const [error, setError] = useState<Error | null>(null);
const [loading, setLoading] = useState(true);
// ... fetch logic
return { data, error, loading, refetch };
}
useCallback for functions passed to children -- prevents unnecessary re-rendersuseMemo only for expensive computations -- don't wrap everythinguseReducer over useState when state transitions are complex// eslint-disable-next-line// Bad -- unnecessary effect
const [fullName, setFullName] = useState("");
useEffect(() => {
setFullName(`${firstName} ${lastName}`);
}, [firstName, lastName]);
// Good -- derived value
const fullName = `${firstName} ${lastName}`;
Use the simplest tier that solves the problem:
| Tier | Tool | When to Use |
|---|---|---|
| 1. Local state | useState, useReducer | Single component state |
| 2. Lifted state | Props, composition | Shared between parent/child |
| 3. Context | createContext + useContext | Theme, auth, locale -- rarely changes |
| 4. URL state | Search params, path params | Filters, pagination, navigation state |
| 5. Server state | React Query / SWR | API data, caching, synchronization |
| 6. Global store | Zustand / Redux Toolkit | Complex client state across many components |
AuthContext, ThemeContext, not AppContextuseMemo on the provider value// Good -- stable context value
function AuthProvider({ children }: { children: ReactNode }) {
const [user, setUser] = useState<User | null>(null);
const value = useMemo(() => ({ user, setUser }), [user]);
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
}
React.memo -- include a custom comparator if props are objectsreact-window or @tanstack/virtual for 100+ itemskey correctly -- stable, unique identifiers, never array index for dynamic lists// Good -- code splitting
const Dashboard = lazy(() => import("./pages/Dashboard"));
function App() {
return (
<Suspense fallback={<Loading />}>
<Routes>
<Route path="/dashboard" element={<Dashboard />} />
</Routes>
</Suspense>
);
}
<button> not <div onClick>, <nav> not <div className="nav">alt="" for decorative images<label htmlFor> or aria-labelaria-expanded, aria-live, role// Good -- accessible modal
function Modal({ isOpen, onClose, title, children }: ModalProps) {
const closeRef = useRef<HTMLButtonElement>(null);
useEffect(() => {
if (isOpen) closeRef.current?.focus();
}, [isOpen]);
if (!isOpen) return null;
return (
<div role="dialog" aria-modal="true" aria-labelledby="modal-title">
<h2 id="modal-title">{title}</h2>
{children}
<button ref={closeRef} onClick={onClose}>
Close
</button>
</div>
);
}
import { ErrorBoundary } from "react-error-boundary";
function ErrorFallback({ error, resetErrorBoundary }: FallbackProps) {
return (
<div role="alert">
<h2>Something went wrong</h2>
<pre>{error.message}</pre>
<button onClick={resetErrorBoundary}>Try again</button>
</div>
);
}
// Usage
<ErrorBoundary FallbackComponent={ErrorFallback}>
<Dashboard />
</ErrorBoundary>
useMemo/useCallback everywhereuseRef onlyWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
/recipe-skills:react-patternsfrom recipe-skills
npx claudepluginhub sagargupta16/claude-code-recipes --plugin recipe-skills5 skills in this plugin
/api-designREST API conventions covering URL structure, HTTP methods, status codes, pagination, filtering, error responses, and versioning. Use when designing or reviewing REST API endpoints, adding routes, or standardizing API error handling./git-workflowGit conventions covering branch naming, conventional commits, PR format, squash strategy, and protected branches. Use when committing, branching, opening PRs, or setting up a git workflow for a project./testing-strategyTesting approach covering unit/integration/e2e split, what to test, AAA test structure, mocking strategies, and coverage targets. Use when writing tests, planning test coverage, or reviewing test quality./typescript-strictStrict TypeScript conventions covering strict mode config, no-any rules, utility types, discriminated unions, branded types, and error handling patterns. Use when writing TypeScript, tightening types, or migrating code to strict mode.