We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 08c8a0f commit ecdbd44Copy full SHA for ecdbd44
1 file changed
src/content/reference/react/useOptimistic.md
@@ -271,17 +271,19 @@ Here's a button that shows "Submitting..." while the Action is pending using the
271
<Sandpack>
272
273
```js src/App.js
274
-import { useState } from 'react';
+import { useState, startTransition } from 'react';
275
import Button from './Button';
276
import { submitForm } from './actions.js';
277
278
export default function App() {
279
const [count, setCount] = useState(0);
280
return (
281
<div>
282
- <Button action={async () => {
+ <Button action={async () => {
283
await submitForm();
284
- setCount(c => c + 1);
+ startTransition(() => {
285
+ setCount(c => c + 1);
286
+ });
287
}}>Increment</Button>
288
{count > 0 && <p>Submitted {count}!</p>}
289
</div>
0 commit comments