React 19.x development patterns and APIs. Use when building React applications with React 19+ features including Actions (useTransition with async), useActionState, useFormStatus, useOptimistic, use() API, Form Actions, ref as prop (no forwardRef), Context as provider, document metadata/stylesheets/scripts, Server Components, Server Actions, prerender(), the Activity component, useEffectEvent, cacheSignal(), and Partial Pre-rendering. Triggers on React 19 questions, form handling, server components, or when using new React 19 APIs.
/plugin marketplace add dionridley/claude-plugins/plugin install engineering-tools@dion-toolsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/actions.mdreferences/improvements.mdreferences/rendering.mdreferences/server-components.mdreferences/use-api.mdThis skill provides guidance on React 19.x features that may not be in LLM training data. Focus is on new APIs, patterns, and migration from older React patterns.
| Hook | Purpose | Import |
|---|---|---|
useActionState | Form state + pending + error handling | react |
useFormStatus | Read parent form's pending state | react-dom |
useOptimistic | Optimistic UI updates | react |
use | Read promises/context conditionally | react |
| Hook | Purpose | Import |
|---|---|---|
useEffectEvent | Stable event handlers in effects | react |
| Component | Purpose |
|---|---|
<Activity> | Control visibility/priority of subtrees |
Handling form submission?
├── Need pending state in child component? → useFormStatus
├── Need optimistic updates? → useOptimistic
├── Need form state + error handling? → useActionState
└── Simple async action? → useTransition with async
Reading async data?
├── In render, with Suspense? → use(promise)
└── In effect/event handler? → Regular await
Reading context conditionally?
└── After early return? → use(Context) instead of useContext
Effect needs reactive value but shouldn't re-run?
└── → useEffectEvent
Conditional rendering with state preservation?
└── → <Activity mode="visible|hidden">
// OLD: Manual state management
function OldForm() {
const [isPending, setIsPending] = useState(false);
const [error, setError] = useState(null);
const handleSubmit = async (e) => {
e.preventDefault();
setIsPending(true);
const result = await submitData(new FormData(e.target));
setIsPending(false);
if (result.error) setError(result.error);
};
return <form onSubmit={handleSubmit}>...</form>;
}
// NEW: Form Actions with useActionState
function NewForm() {
const [error, submitAction, isPending] = useActionState(
async (prevState, formData) => {
const result = await submitData(formData);
if (result.error) return result.error;
redirect('/success');
return null;
},
null
);
return (
<form action={submitAction}>
<input name="field" />
<button disabled={isPending}>Submit</button>
{error && <p>{error}</p>}
</form>
);
}
// OLD: Required forwardRef wrapper
const OldInput = forwardRef(function OldInput({ label }, ref) {
return <input ref={ref} aria-label={label} />;
});
// NEW: ref is just a prop
function NewInput({ label, ref }) {
return <input ref={ref} aria-label={label} />;
}
// Both used the same way
<NewInput ref={inputRef} label="Name" />
// OLD
<ThemeContext.Provider value={theme}>
{children}
</ThemeContext.Provider>
// NEW
<ThemeContext value={theme}>
{children}
</ThemeContext>
// useContext cannot be called after early return
function Component({ show }) {
if (!show) return null;
// const theme = useContext(ThemeContext); // ERROR!
const theme = use(ThemeContext); // OK!
return <div style={{ color: theme.color }}>...</div>;
}
// OLD: Unmounts and loses state
{isVisible && <ExpensiveComponent />}
// NEW: Preserves state, defers updates when hidden
<Activity mode={isVisible ? 'visible' : 'hidden'}>
<ExpensiveComponent />
</Activity>
// Problem: theme change causes reconnect
function ChatRoom({ roomId, theme }) {
useEffect(() => {
const conn = connect(roomId);
conn.on('connected', () => showNotification(theme));
return () => conn.disconnect();
}, [roomId, theme]); // theme shouldn't trigger reconnect!
}
// Solution: useEffectEvent
function ChatRoom({ roomId, theme }) {
const onConnected = useEffectEvent(() => {
showNotification(theme); // Always reads latest theme
});
useEffect(() => {
const conn = connect(roomId);
conn.on('connected', onConnected);
return () => conn.disconnect();
}, [roomId]); // Only roomId triggers reconnect
}
(previousState, formData) - don't forget previousState[state, action, isPending] - order mattersuseFormState in React DOM<form>{ pending, data, method, action }startTransition or form actionsuse()// NEW: Cleanup function syntax
<input
ref={(node) => {
// Setup
node.focus();
return () => {
// Cleanup when ref changes or unmounts
};
}}
/>
// BREAKING: Implicit returns now fail TypeScript
<div ref={current => (instance = current)} /> // BAD
<div ref={current => { instance = current; }} /> // GOOD
For detailed documentation on specific topics:
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.