React Cheat Sheet
A searchable, printable React 19 reference — components, JSX, hooks, the new Actions APIs, context, refs and performance. Free.
Components & JSX
12function App() { return <h1>Hi</h1>; }
export default function App() {}
<Greeting name="Ada" />
{1 + 2} or {user.name}
<>{a}{b}</>
<div className="card">
{isOpen && <Menu />}
{ok ? <Yes /> : <No />}
{items.map(i => <li key={i.id}>{i.t}</li>)}
function Btn({ label, onClick }) {}
function Card({ children }) { return children; }
<input value={v} onChange={onChange} />
Rendering & setup
10import { createRoot } from 'react-dom/client'
createRoot(document.getElementById('root')).render(<App/>)
import { StrictMode } from 'react'
<StrictMode><App /></StrictMode>
import { hydrateRoot } from 'react-dom/client'
hydrateRoot(el, <App />)
root.unmount()
import App from './App.jsx'
<App {...props} />
export { Button, Card }
State & effects
12const [count, setCount] = useState(0)
setCount(c => c + 1)
setUser(u => ({ ...u, name }))
useEffect(() => { run(); }, [dep])
useEffect(() => { /* once */ }, [])
useEffect(() => () => cleanup(), [])
const ref = useRef(null)
const [state, dispatch] = useReducer(r, init)
const theme = useContext(ThemeContext)
const memo = useMemo(() => calc(a), [a])
useLayoutEffect(() => {}, [])
useSyncExternalStore(sub, get)
React 19 hooks & APIs
12import { use } from 'react'
const data = use(promise)
const theme = use(ThemeContext)
const [state, action, pending] = useActionState(fn, init)
const [opt, addOpt] = useOptimistic(state, reducer)
const { pending } = useFormStatus()
const [isPending, startTransition] = useTransition()
startTransition(async () => await save())
const deferred = useDeferredValue(value)
const id = useId()
<title>Page title</title>
function Input({ ref }) {}
Forms & Actions
12<form action={handleSubmit}>
function handleSubmit(formData) {}
formData.get('email')
const [state, action] = useActionState(submit, null)
<form action={action}>
const [s, a, pending] = useActionState(fn, init)
return { error: 'Invalid' }
function Submit() { const { pending } = useFormStatus() }
<button disabled={pending}>Save</button>
import { requestFormReset } from 'react-dom'
requestFormReset(formEl)
<form action={action}><Submit /></form>
Props & composition
10function Hi({ name = 'Guest' }) {}
function Box({ children }) { return children; }
<Box><p>Inside</p></Box>
function List({ render }) { return render(); }
<List render={() => <Item />} />
<Input {...props} />
const { id, ...rest } = props
<Avatar {...rest} size="lg" />
function Btn(props: BtnProps) {}
<Slot label={<b>Hi</b>} />
Events
10<button onClick={handleClick}>
function handleClick(e) {}
<input onChange={e => set(e.target.value)} />
<form onSubmit={e => e.preventDefault()}>
e.stopPropagation()
<li onClick={() => remove(id)}>
<input onKeyDown={e => e.key === 'Enter'}
<div onMouseEnter={hover}>
e.currentTarget.value
<button onClick={() => {}} type="button">
Lists & keys
10arr.map(x => <li key={x.id}>{x.t}</li>)
key={item.id}
key={index}
users.map(u => <Card key={u.id} {...u} />)
{list.length === 0 && <Empty />}
import { Fragment } from 'react'
<Fragment key={id}>{a}{b}</Fragment>
{rows.filter(r => r.on).map(...)}
Keys must be unique among siblings
{[...Array(n)].map((_, i) => ...)}
Context
10const ThemeContext = createContext('light')
import { createContext } from 'react'
<ThemeContext value={theme}>
<ThemeContext value={theme}><App /></ThemeContext>
const theme = useContext(ThemeContext)
const theme = use(ThemeContext)
if (cond) { const t = use(Ctx); }
export const ThemeContext = createContext()
<Ctx value={{ user, setUser }}>
Avoid new objects each render
Refs
10const inputRef = useRef(null)
<input ref={inputRef} />
inputRef.current.focus()
function Field({ ref }) { return <input ref={ref} /> }
<Field ref={inputRef} />
useImperativeHandle(ref, () => ({ focus }))
const setRef = node => { box = node; }
<div ref={setRef} />
const count = useRef(0)
ref={node => { return () => cleanup(); }}
Performance
10const Memo = memo(Component)
import { memo } from 'react'
const value = useMemo(() => calc(a), [a])
const fn = useCallback(() => f(a), [a])
const Lazy = lazy(() => import('./Big.jsx'))
import { lazy, Suspense } from 'react'
<Suspense fallback={<Spin />}><Lazy /></Suspense>
startTransition(() => setQuery(q))
const slow = useDeferredValue(query)
React Compiler auto-memoizes
Misc & metadata
10<Suspense fallback={<Loading />}>
class ErrorBoundary extends Component {}
<title>My Page</title>
<meta name="description" content="..." />
<link rel="stylesheet" href="..." />
<Comp key={id} />
React.lazy(() => import('./Page.jsx'))
createPortal(node, container)
{/* a comment */}
cleanup return in useEffect
No entry matches “:q”.
About React Cheat Sheet
This React cheat sheet targets React 19 and maps the library by concept: components and JSX, rendering and setup, state and effects, the React 19 hooks and APIs, forms and Actions, props and composition, events, lists and keys, context, refs, performance, and metadata plus miscellany.
It covers both the fundamentals you use in every component — useState, useEffect, props, keys, controlled inputs — and the newer React 19 additions, including the Actions-based form patterns, so it works as a refresher and as a bridge to the current APIs.
The sheet is free and client-side. Filter hooks and patterns live with the search box, jump between sections from the sticky table of contents, copy any snippet with one click and print the page as a reference while you build components.
How to use React Cheat Sheet
- Skim the sections, from Components & JSX and State & effects to React 19 hooks & APIs and Performance.
- Search for a hook or concept like useEffect, key or context to filter the sheet live.
- Jump to Forms & Actions or Refs via the sticky sidebar when you need a specific pattern.
- Click a snippet or its copy icon to copy the code into your component.
- Print the sheet for an offline React reference.