Skip to content

Commit 2d7fd58

Browse files
committed
docs: update nextjs documentation
1 parent 6ec6017 commit 2d7fd58

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

apps/docs/content/en/docs/01-app/01-getting-started/10-updating-data.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,15 @@ While executing a Server Function, you can show a loading indicator with React's
259259
```tsx filename="app/ui/button.tsx" switcher
260260
'use client'
261261

262-
import { useActionState } from 'react'
262+
import { useActionState, startTransition } from 'react'
263263
import { createPost } from '@/app/actions'
264264
import { LoadingSpinner } from '@/app/ui/loading-spinner'
265265

266266
export function Button() {
267267
const [state, action, pending] = useActionState(createPost, false)
268268

269269
return (
270-
<button onClick={async () => action()}>
270+
<button onClick={() => startTransition(action)}>
271271
{pending ? <LoadingSpinner /> : 'Create Post'}
272272
</button>
273273
)
@@ -277,15 +277,15 @@ export function Button() {
277277
```jsx filename="app/ui/button.js" switcher
278278
'use client'
279279

280-
import { useActionState } from 'react'
280+
import { useActionState, startTransition } from 'react'
281281
import { createPost } from '@/app/actions'
282282
import { LoadingSpinner } from '@/app/ui/loading-spinner'
283283

284284
export function Button() {
285285
const [state, action, pending] = useActionState(createPost, false)
286286

287287
return (
288-
<button onClick={async () => action()}>
288+
<button onClick={() => startTransition(action)}>
289289
{pending ? <LoadingSpinner /> : 'Create Post'}
290290
</button>
291291
)

0 commit comments

Comments
 (0)