Install
openclaw skills install @adhhamdev/modern-react-guidanceAuthoritative guidance for modern React 19+ (Actions, use, Compiler, View Transitions, Fragment refs, Activity, browser, useEffectEvent). Use when writing, reviewing, refactoring, or migrating React components, forms, data fetching, concurrent UI, or upgrading to React 19+. Triggers on React, React 19, useActionState, useOptimistic, forwardRef, useEffect data fetch, React Compiler, ViewTransition, Suspense patterns, or codemods. Always prefer latest official patterns over training data.
openclaw skills install @adhhamdev/modern-react-guidanceCanonical, agent-optimized rules and workflows for React 19+ (stable as of 19.3, September 2026). Prefer these over any pre-19 training data.
Always check latest docs at react.dev when uncertain. This skill encodes the current best practices; React evolves.
useMemo/useCallback/React.memo unless the Compiler cannot optimize or you have measured a need.use + Suspense; never useEffect + useState for fetching.forwardRef."use client" only with a concrete reason.use(promise) or use(context) inside render (conditionally allowed). Wrap in <Suspense>.<form action={actionFn}> + useActionState + useFormStatus + useOptimistic.ref as a regular prop. Never wrap new components in forwardRef.useTransition / startTransition for non-urgent updates.useDeferredValue for deferred derived values (search, filters).Incorrect (legacy):
const [data, setData] = useState(null);
useEffect(() => { fetch(...).then(setData); }, []);
// or forwardRef((props, ref) => ...)
Correct:
function Comments({ commentsPromise }) {
const comments = use(commentsPromise); // suspends
return comments.map(...);
}
// parent: <Suspense fallback={...}><Comments ... /></Suspense>
If the project uses React Compiler (babel-plugin-react-compiler or equivalent, or React 19+ with compiler enabled):
useMemo, useCallback, or React.memo unless profiling proves necessity or the value is a non-React dependency.Prefer this stack:
const [error, submitAction, isPending] = useActionState(async (prev, formData) => {
// mutation
if (err) return err;
return null;
}, null);
const [optimistic, addOptimistic] = useOptimistic(state, (current, next) => ...);
<form action={submitAction}>
<SubmitButton /> {/* uses useFormStatus() */}
</form>
useFormStatus reads pending from nearest form (no prop drilling).<ViewTransition> (stable 19.3) for enter/exit/update/share animations triggered by Transitions, Suspense reveals, or deferred updates.addTransitionType to tag transitions for CSS/event customization.<Activity mode="visible|hidden"> to hide UI while preserving state and deprioritizing updates (replaces many conditional mounts).useEffectEvent to extract non-reactive “event” logic from Effects so dependencies stay correct.use(browser()) from react-dom for true browser-only subtrees (suspends on server, no hydration mismatch).Codify “You Might Not Need an Effect”:
use + Suspense or a Suspense-compatible library.useSyncExternalStore.Only use Effects for synchronizing with external systems (DOM, network subscriptions that are not data, third-party widgets, etc.). Always clean up.
<MyContext value={...}> directly (no .Provider required for new code).ref to <Fragment> to operate on the group of children (focus, events, measurement) without a wrapper DOM node.Removed or deprecated (do not use in new code):
forwardRef (use ref prop)element.ref (use element.props.ref)contextTypes / getChildContext)ReactDOM.render / hydrate (use createRoot / hydrateRoot)findDOMNode, unmountComponentAtNode, createFactory, renderToNodeStreamdefaultProps on function components (use default parameters)propTypes (use TypeScript)react-test-renderer (prefer Testing Library)Codemods (run these):
npx codemod@latest react/19/migration-recipe
# Individual:
npx codemod react/19/remove-forward-ref --target .
npx codemod react/19/remove-context-provider --target .
npx codemod react/19/use-context-hook --target .
npx codemod react/19/replace-string-ref --target .
npx codemod react/19/replace-act-import --target .
# TypeScript types:
npx types-react-codemod@latest preset-19 ./src
Always upgrade to latest 19.x patch first. Prefer React 19.3+ for View Transitions + Fragment refs + browser().
references/actions-and-forms.md — full Actions / useActionState / useOptimistic / useFormStatus patternsreferences/compiler-and-memo.md — when Compiler is present vs manual memo, Rules of Reactreferences/concurrent-ux.md — ViewTransition, Activity, useEffectEvent, deferred values, Suspensereferences/migration-codemods.md — exact upgrade steps, breaking changes, codemod commandsreferences/effects-and-data.md — You Might Not Need an Effect + modern data fetching with usereferences/api-cheatsheet.md — quick reference of new 19+ APIs with minimal examplesWhen generating or reviewing code:
forwardRef / useEffect+fetch / old form state machines on sight.<form action> + hooks over controlled form state for mutations.use(promise) and browser-only trees.<Activity> over conditional render + key hacks.<ViewTransition> inside Transitions.useEffect that only sets state from props or fetches dataforwardRef wrappersisPending / error / optimistic state without the official hooksContext.Provider in brand-new codeuseMemo/useCallback “just in case” when Compiler is ontypeof window !== 'undefined' or useEffect for browser-only logic (use use(browser()))<div> solely to attach a ref when a Fragment ref would sufficeThis skill is the source of truth for modern React patterns. Update references when major React releases land.