React 19 Cheatsheet
React 19 Cheatsheet
c h e at s h e e t
by
Sonny Sangha
J o i n Z e r o t o F u l l S t a c k H e r o & L e a r n t o C o d e T o d a y : h t t p s : // w w w . p a p a r e a c t. c o m / c o u r s e
Join Zero to Full Stack Hero & Learn to Code Today: https://www.papareact.com/course
Join Zero to Full Stack Hero & Learn to Code Today: https://www.papareact.com/course
table of contents
React Server Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
useActionState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
useFormStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
useOptimistic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
‘use client’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
‘use server’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
ref as a Prop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3
Join Zero to Full Stack Hero & Learn to Code Today: https://www.papareact.com/course
/ dashboard.tsx
import * as db from ‘./db.ts’
import { createOrg } from ‘./org-actions.ts’
import { OrgPicker } from ‘./org-picker.tsx’
4
Join Zero to Full Stack Hero & Learn to Code Today: https://www.papareact.com/course
Actions
Async functions that handle form submission, error states, and optimistic updates
automatically.
useActionState
Manages form state, providing degraded experiences when JavaScript is unavailable.
useFormStatus
Access the status of a parent form without prop drilling.
useOptimistic
Show optimistic state while async requests are in progress.
5
Join Zero to Full Stack Hero & Learn to Code Today: https://www.papareact.com/course
‘use client’
Marks code that can be referenced by the server component and can use client-side
React features.
// org-picker.tsx
‘use client’
6
Join Zero to Full Stack Hero & Learn to Code Today: https://www.papareact.com/course
‘use server’
Marks server-side functions callable from client-side code.
// org-actions.ts
‘use server’
<title>My Blog</title>
<meta name=“author” content=“Kent” />
7
Join Zero to Full Stack Hero & Learn to Code Today: https://www.papareact.com/course
createRoot(container, {
onCaughtError: (error, errorInfo) => {
console.error(
‘Caught error’,
error,
errorInfo.componentStack
);
},
onUncaughtError: (error, errorInfo) => {
console.error(
‘Uncaught error’,
error,
errorInfo.componentStack
);
},
});
8
Join Zero to Full Stack Hero & Learn to Code Today: https://www.papareact.com/course
use
Reads resources like promises or context during render, allowing for conditional use.
<LanguageContext value=“pl-PL”>{children}</LanguageContext>
9
Join Zero to Full Stack Hero & Learn to Code Today: https://www.papareact.com/course
ref as a Prop
Pass refs directly as props in function components.
10
Join Zero to Full Stack Hero & Learn to Code Today: https://www.papareact.com/course
11