File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
src/content/reference/react Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff 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' ;
275275import Button from ' ./Button' ;
276276import { submitForm } from ' ./actions.js' ;
277277
278278export 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>
You can’t perform that action at this time.
0 commit comments