skills/react-19/SKILL.md
React 19 patterns with React Compiler. Automatic optimization, Server Components, use() hook. Trigger: When building React components, using hooks, working with forms, or server/client components.
npx skillsauth add fearovex/claude-config react-19Install this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Triggers: When building React components, using hooks, working with forms, or server/client components.
Load when: writing React components, using hooks, handling forms, working with Server/Client components, or migrating from React 18.
// ✅ React Compiler optimizes this automatically
function ExpensiveComponent({ data }: { data: number[] }) {
const result = data.reduce((acc, n) => acc + n, 0); // Compiler memoizes it
return <div>{result}</div>;
}
// ❌ Unnecessary in React 19 with Compiler enabled
function ExpensiveComponent({ data }: { data: number[] }) {
const result = useMemo(() => data.reduce((acc, n) => acc + n, 0), [data]);
return <div>{result}</div>;
}
// ✅ Always named imports
import { useState, useEffect, use, useActionState } from 'react';
import { Suspense } from 'react';
// ❌ Never default or namespace imports
import React from 'react';
import * as React from 'react';
// ✅ Server Component (default — no directive needed)
async function UserProfile({ userId }: { userId: string }) {
const user = await db.users.findById(userId); // Direct DB access
return <div>{user.name}</div>;
}
// ✅ Client Component — only when you need interactivity
'use client';
function Counter() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(c => c + 1)}>{count}</button>;
}
'use client';
import { use, Suspense } from 'react';
// Read promise in render
function UserData({ promise }: { promise: Promise<User> }) {
const user = use(promise); // Suspends until resolved
return <div>{user.name}</div>;
}
// Usage with Suspense
function App() {
const userPromise = fetchUser(userId);
return (
<Suspense fallback={<Skeleton />}>
<UserData promise={userPromise} />
</Suspense>
);
}
// Conditional context (impossible with useContext)
function ConditionalTheme({ show }: { show: boolean }) {
if (!show) return null;
const theme = use(ThemeContext); // ✅ conditional usage OK
return <div style={{ color: theme.primary }}>themed</div>;
}
'use server';
async function createUser(prevState: State, formData: FormData) {
const name = formData.get('name') as string;
if (!name) return { error: 'Name required' };
await db.users.create({ name });
revalidatePath('/users');
return { success: true };
}
// Client Component
'use client';
import { useActionState } from 'react';
function CreateUserForm() {
const [state, action, isPending] = useActionState(createUser, null);
return (
<form action={action}>
<input name="name" />
<button disabled={isPending}>
{isPending ? 'Creating...' : 'Create'}
</button>
{state?.error && <p>{state.error}</p>}
</form>
);
}
// ✅ React 19 — ref is a standard prop
function Input({ ref, ...props }: React.InputHTMLAttributes<HTMLInputElement> & {
ref?: React.Ref<HTMLInputElement>
}) {
return <input ref={ref} {...props} />;
}
// ❌ No longer needed
const Input = forwardRef<HTMLInputElement, Props>((props, ref) => (
<input ref={ref} {...props} />
));
// ✅ Server Component with parallel fetching
async function Dashboard() {
const [user, posts, stats] = await Promise.all([
fetchUser(),
fetchPosts(),
fetchStats(),
]);
return (
<div>
<UserCard user={user} />
<PostList posts={posts} />
<StatsPanel stats={stats} />
</div>
);
}
// ❌ Redundant with React Compiler
const value = useMemo(() => compute(data), [data]);
const handler = useCallback(() => doThing(id), [id]);
// ✅ Simple and direct
const value = compute(data);
const handler = () => doThing(id);
// ❌ Makes the entire tree client-side
'use client';
export default function Page() { /* ... */ }
// ✅ Only the interactive component
// page.tsx (Server Component)
export default function Page() {
return (
<div>
<StaticContent />
<InteractiveWidget /> {/* 'use client' only here */}
</div>
);
}
| Feature | React 18 | React 19 | |---------|----------|----------| | Memoization | Manual useMemo/useCallback | Automatic (Compiler) | | Promises | useEffect + useState | use() hook | | Forms | onSubmit handler | Server Actions + useActionState | | Refs in components | forwardRef | ref as prop | | Conditional context | ❌ Not possible | ✅ use() |
useMemo or useCallback when React Compiler is active — the compiler handles memoization automatically and manual wrapping is redundant'use client' must be applied at the lowest possible component in the tree; never mark a page or layout as a Client ComponentforwardRef is no longer needed — pass ref as a regular prop; using forwardRef in new React 19 code is unnecessary legacy syntaxuse() hook can be called conditionally (unlike all other hooks); this is intentional and must be used instead of conditional useContext workaroundsuseActionState for form state management; managing form submission state manually with useState + useEffect is the old patternbusiness
Turns an already-investigated customer issue into a short, non-technical engineering-to-CS brief: one natural message that leads with the finding (root cause, real scope, open question), ready to paste into Slack for the support team. Trigger: /support-brief, support brief, brief for support, resumen soporte.
development
Parks the current Claude Code session before going to sleep. Analyzes the conversation, writes a handoff document to docs/handoffs/ in the current project, mirrors the same summary to engram tagged with the session ID, and prints the exact `claude --resume <id>` command for tomorrow. Zero interaction — runs end-to-end on a single invocation. Trigger: /night-park, night park, park session, me voy a dormir, guardar sesion.
testing
Interactive creator for a project feature: scaffolds the domain knowledge markdown at ai-context/features/<slug>.md AND the antenna skill at .claude/skills/<slug>/SKILL.md, both from the canonical templates. Also registers the antenna in the project's CLAUDE.md. Trigger: /feature-define <name>, define feature, documentar funcionalidad, nueva feature.
data-ai
Generates a short, non-technical, informal English summary of an already-investigated customer issue, ready to paste into Slack/email for support, CX, or ops teammates. Trigger: /customer-summary, customer summary, resumir customer issue, slack summary.