React useOptimistic: show an update before it finishes
Answer: useOptimistic is a React Hook that lets you optimistically update the UI. The first argument is the value returned when there are no pending Actions. An optional reducer function specifies how the optimistic state is computed from the current state and an action.
Examples
import { useOptimistic } from 'react';
function Form({ message }) {
const [optimistic, addOptimistic] = useOptimistic(message, (current, next) => next);
return <button onClick={() => addOptimistic("saved")}>Save</button>;
}
Notes
You can pass the next state directly, or compute it in the reducer.
Reference list
useOptimisticlets you optimistically update the UI.Thefirst value is used when there are no pending Actions.optionalAn optional reducer specifies how the optimistic state is computed.
See also
Claims
- id: C1 claim: useOptimistic lets you optimistically update the UI. source: S1 evidence: "useOptimistic is a React Hook that lets you optimistically update the UI"
- id: C2 claim: The first value is used when there are no pending Actions. source: S2 evidence: "The value returned when there are no pending Actions"
- id: C3 claim: An optional reducer specifies how the optimistic state is computed. source: S2 evidence: "The reducer function that specifies how the optimistic"
Sources
- [S1] useOptimistic. React docs. https://react.dev/reference/react/useOptimistic . License: CC-BY-4.0. Accessed 2026-11-18.
- [S2] useOptimistic.md. reactjs/react.dev. https://github.com/reactjs/react.dev/blob/main/src/content/reference/react/useOptimistic.md . License: CC-BY-4.0. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: React docs, useOptimistic; reactjs/react.dev, useOptimistic.md. CC-BY-4.0 (https://raw.githubusercontent.com/reactjs/react.dev/main/LICENSE-DOCS.md). Copyright Meta Platforms, Inc. and affiliates. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: React docs, useOptimistic; reactjs/react.dev, useOptimistic.md. CC-BY-4.0 (https://raw.githubusercontent.com/reactjs/react.dev/main/LICENSE-DOCS.md). Copyright Meta Platforms, Inc. and affiliates.
Cite this
iinventedlight. 2026. "React useOptimistic: show an update before it finishes." iinventedlight Library, iil:note:1x5fsdm6, version of 2026-11-18. https://iinventedlight.com/library/notes/react-useoptimistic/. License: CC-BY-4.0.
@misc{iil_note_1x5fsdm6,
author = {{iinventedlight}},
title = {{React useOptimistic: show an update before it finishes}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/react-useoptimistic/},
note = {Permanent ID iil:note:1x5fsdm6. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- react-useoptimistic.table.json (table; CC-BY-4.0)
- react-useoptimistic.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/react-useoptimistic.md.