Skip to content
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ed87618
Update DoS blog post with additional CVE (#8263)
rickhanlonii Jan 26, 2026
303e6b4
Init claude config (#8265)
rickhanlonii Jan 27, 2026
3938fbf
Update deps (#8268)
rickhanlonii Jan 28, 2026
dcc5deb
Add llms.txt (#8267)
gaearon Jan 28, 2026
61b1f51
Add sections to llms.txt and sitemap footer to *.md (#8270)
rickhanlonii Jan 28, 2026
d340c41
Remove feedback (#8271)
rickhanlonii Jan 28, 2026
a2a19ba
feat: Add Accept header content negotiation for markdown (#8272)
icyJoseph Jan 28, 2026
ec13a90
remove outdated note about streaming ssr (#8277)
hernan-yadiel Jan 29, 2026
24ec67e
fix: use beforeFiles (#8276)
icyJoseph Jan 30, 2026
29743d0
Revamp useOptimistic docs (#8264)
rickhanlonii Jan 30, 2026
4c52ab8
Update separating-events-from-effects.md (#8257)
wheresrhys Jan 30, 2026
38b52cf
More claude stuff (#8280)
rickhanlonii Jan 30, 2026
ff17a86
fix: correct typos and improve clarity in useOptimistic.md (#8283)
aurorascharff Feb 2, 2026
e05afa5
useEffectEvent revamp (#8279)
rickhanlonii Feb 4, 2026
bd87c39
Rephrase the rendering explanation paragraph (#8240)
BartoszKlonowski Feb 5, 2026
f653b03
Add .worktrees/ to .gitignore (#8297)
rickhanlonii Feb 10, 2026
46e040e
Fix date of CVE-2026-23864 (2025 => 2026) (#8302)
smikitky Feb 11, 2026
a19c98d
Fix confusion around Activity with text children (#8304)
eps1lon Feb 12, 2026
55a317d
Rewrite useActionState (#8284)
rickhanlonii Feb 15, 2026
a1cc2ab
Added missing prop to useActionState example (#8308)
JakeSaterlay Feb 17, 2026
c2aa350
Expand ViewTransition callback props reference documentation (#8306)
rickhanlonii Feb 23, 2026
68ff8c8
Add blog post: Launching the React Foundation (#8318)
mattcarrollcode Feb 24, 2026
e8ef063
Update logo credit link in uwu mode console log (#8315)
Cheesecake2960 Feb 25, 2026
dfa152b
[ViewTransition] Add docs for using with Activity (#8320)
rickhanlonii Feb 25, 2026
11e4ad5
Add /write command (#8327)
rickhanlonii Feb 27, 2026
427f24d
Add RSC Sandboxes (#8300)
rickhanlonii Feb 28, 2026
180364f
Add Copy Page button (#8341)
gaearon Mar 8, 2026
449d62c
Add ZurichJS Conference 2026 to community conferences
farisaziz12 Mar 8, 2026
7c90c6e
Update conferences: move past events (Sep 2025 – Feb 2026) to Past se…
aurorascharff Mar 8, 2026
40ea071
Fix copy button on Safari
gaearon Mar 9, 2026
754a2f8
merging all conflicts
react-translations-bot Mar 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: correct typos and improve clarity in useOptimistic.md (#8283)
  • Loading branch information
aurorascharff authored Feb 2, 2026
commit ff17a86ec8c667de2138031ccca178af37925097
14 changes: 8 additions & 6 deletions src/content/reference/react/useOptimistic.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ This state is called the "optimistic" because it is used to immediately present

4. **(Optional) wait for Suspense**: If `newValue` suspends, React continues showing `'b'`.

5. **Single render commit**: Finally, the `newValue` is commits for `value` and `optimistic`.
5. **Single render commit**: Finally, the `newValue` commits for `value` and `optimistic`.

There's no extra render to "clear" the optimistic state. The optimistic and real state converge in the same render when the Transition completes.

<Note>

#### Optimistic state is temporary {/*optimistic-state-is-temporary*/}

Optimistic state is only renders while an Action is in progress, otherwise `value` is rendered.
Optimistic state only renders while an Action is in progress, otherwise `value` is rendered.

If `saveChanges` returned `'c'`, then both `value` and `optimistic` will be `'c'`, not `'b'`.

Expand Down Expand Up @@ -403,7 +403,7 @@ export default function App() {
}

if (optimisticIsLiked !== isLiked) {
console.log('✅ rendering optmistic state: ' + optimisticIsLiked);
console.log('✅ rendering optimistic state: ' + optimisticIsLiked);
} else {
console.log('✅ rendering real value: ' + optimisticIsLiked);
}
Expand Down Expand Up @@ -1061,7 +1061,7 @@ If the values are not equal, there's a Transition in progress.

2. **Add a `useTransition`**

```
```js
const [isPending, startTransition] = useTransition();
const [optimistic, setOptimistic] = useOptimistic(value);

Expand All @@ -1071,13 +1071,15 @@ startTransition(() => {
})
```

Since `useTransition` uses `useOptimsitic` for `isPending` under the hood, this is equivalent to option 1.
Since `useTransition` uses `useOptimistic` for `isPending` under the hood, this is equivalent to option 1.

3**Add a `pending` flag in your reducer**
3. **Add a `pending` flag in your reducer**

```js
const [optimistic, addOptimistic] = useOptimistic(
items,
(state, newItem) => [...state, { ...newItem, isPending: true }]
);
```

Since each optimistic item has its own flag, you can show loading state for individual items.