use, useActionState, useFormStatus & useOptimistic in React
From the React Hooks cheat sheet ยท React 19 Hooks ยท verified Nov 2026
use, useActionState, useFormStatus & useOptimistic
New hooks introduced in React 19 for promises, forms, and optimistic UI.
tsx
// === use() - read a promise/context inside a component ===
import { use, Suspense } from 'react'
function UserName({ userPromise }: { userPromise: Promise<User> }) {
const user = use(userPromise) // Suspends until resolved
return <p>Hello, {user.name}</p>
}
// Wrap with Suspense - the promise must be cached (e.g. created in a
// Server Component), not created during a client render
<Suspense fallback={<p>Loading...</p>}>
<UserName userPromise={userPromise} />
</Suspense>
// === useActionState - form/action state + pending flag ===
import { useActionState } from 'react'
async function submitAction(prev: State, formData: FormData): Promise<State> {
const name = formData.get('name')
// ... server call ...
return { ok: true, name }
}
function MyForm() {
const [state, formAction, isPending] = useActionState(submitAction, { ok: false })
return (
<form action={formAction}>
<input name="name" />
<button disabled={isPending}>{isPending ? 'Saving...' : 'Save'}</button>
</form>
)
}
// === useFormStatus - pending state of the enclosing <form> ===
import { useFormStatus } from 'react-dom'
function SubmitButton() {
const { pending } = useFormStatus() // Reads parent <form>
return <button disabled={pending}>{pending ? 'Sending...' : 'Submit'}</button>
}
// === useOptimistic - instant UI while async work runs ===
import { useOptimistic, startTransition } from 'react'
function Likes({ count, like }: { count: number; like: () => Promise<void> }) {
const [optimisticCount, addOptimistic] = useOptimistic(
count,
(current, _: void) => current + 1,
)
// The setter must run inside an Action or startTransition
const onLike = () => startTransition(async () => {
addOptimistic()
await like()
})
return (
<button onClick={onLike}>
๐ {optimisticCount}
</button>
)
}๐ก use() reads a cached promise (or context) and suspends - wrap in Suspense
โก useActionState replaces useFormState - wraps a server/client action with state + pending
๐ useFormStatus reads the parent <form>'s pending state - only works in children
๐ฅ useOptimistic shows an instant UI update while an async action is in flight
Continue with React Hooks
Save the full cheat sheet or work through every related task.