// REF. 11 / COMPONENTS
React cheat sheet
The hooks you reach for every day, the Actions and form APIs that arrived with React 19, and the server/client boundary in one glance. Current to React 19.3, so use(), useActionState, useEffectEvent, <Activity> and <ViewTransition> are all here.
Two habits worth the desk space: pass ref as a plain prop (no more forwardRef), and put async work inside startTransition so the UI stays responsive while it runs.
↓ Download the printable PDF free · letter size · no email needed
State & effects
useState(init)- state and setter; setter re-renders
setX(v => v + 1)- update from the previous value
useReducer(fn, init)- state via (state, action) => next
useEffect(fn, [deps])- sync with outside systems, after paint
return () => cleanup- runs before re-run and on unmount
useEffect(fn, [])- run once after mount
useLayoutEffect- fires before paint; measure layout
Refs & memo
useRef(init)- .current persists; no render on change
ref={inputRef}- attach to a DOM node
ref as a prop- function components take it; no forwardRef
ref={el => () => ...}- callback may return a cleanup
useMemo(() => v, [deps])- cache an expensive value
useCallback(fn, [deps])- cache a function identity
Context & async
createContext(default)- make a context
<Ctx value={v}>- provider; .Provider no longer needed
useContext(Ctx)- read the nearest provider
use(Ctx)- same, but allowed inside if and loops
use(promise)- suspends until resolved; cache the promise
useTransition()- [isPending, startTransition]
startTransition(async)- non-blocking update; an Action
useDeferredValue(v)- let a slow part lag behind the input
Actions & forms
<form action={fn}>- fn gets FormData; resets on success
useActionState(fn, init)- [state, action, isPending]
useFormStatus()- {pending, data} of the parent form
useOptimistic(value)- [optimistic, set]; reverts when done
setOptimistic(next)- only inside an Action
import from 'react-dom'- useFormStatus lives there, not react
Server
'use client'- top of file; marks the client boundary
'use server'- marks Server Functions, not components
async function Page()- server components can await
no hooks on the server- no useState, useEffect, onClick
pass promise, use() it- start on the server, read on the client
<Suspense fallback>- show fallback while children suspend
serializable props only- across the server/client boundary
Rules
key={item.id}- unique among siblings, stable
key={index}- only if the list never reorders
key={Math.random()}- never; remounts every render
hooks at top level- never inside if, loops, or after return
hooks from React fns- components or custom useX only
render must be pure- same props and state, same output
<Component />- never call Component() yourself
New in 19.2 / 19.3
useEffectEvent(fn)- latest props in an effect, not a dep
<Activity mode="hidden">- keep a subtree alive, deprioritized
<ViewTransition>- animate enter, exit, move via the browser
addTransitionType(t)- pick an animation per update kind
<Fragment ref={r}>- a handle to a group of siblings
<title> <meta> anywhere- hoisted into the head
Here be dragons
useEffect(fn) no deps- runs after every render
setState in render- infinite loop, — with a stack trace
setN(n + 1) twice- stale closure; use the updater form
{} or [] in deps- new object each render; effect every time
// KEEP IT UNDER YOUR KEYBOARD
React Field Manual Desk Mat
from $34 · printed to order in the USA