Skip to content

Commit ecdbd44

Browse files
committed
fml, forgot startTransition again
1 parent 08c8a0f commit ecdbd44

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/content/reference/react/useOptimistic.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,17 +271,19 @@ Here's a button that shows "Submitting..." while the Action is pending using the
271271
<Sandpack>
272272
273273
```js src/App.js
274-
import { useState } from 'react';
274+
import { useState, startTransition } from 'react';
275275
import Button from './Button';
276276
import { submitForm } from './actions.js';
277277

278278
export default function App() {
279279
const [count, setCount] = useState(0);
280280
return (
281281
<div>
282-
<Button action={async () => {
282+
<Button action={async () => {
283283
await submitForm();
284-
setCount(c => c + 1);
284+
startTransition(() => {
285+
setCount(c => c + 1);
286+
});
285287
}}>Increment</Button>
286288
{count > 0 && <p>Submitted {count}!</p>}
287289
</div>

0 commit comments

Comments
 (0)