Unverified Commit 322ecdf2 authored by Gediminas's avatar Gediminas Committed by GitHub

Update 02-server-actions-and-mutations.mdx (#64248)

### Improving Documentation

mistake in the docs.

action should not be apply on the button.
only formAction or onClick is allow.

---------
Co-authored-by: 's avatarSam Ko <sam@vercel.com>
parent cb60718b
......@@ -917,6 +917,7 @@ export function addItem() {
Defining a Server Action inside a component creates a [closure](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures) where the action has access to the outer function's scope. For example, the `publish` action has access to the `publishVersion` variable:
```tsx filename="app/page.tsx" switcher
'use client'
export default function Page() {
const publishVersion = await getLatestVersion();
......@@ -928,11 +929,12 @@ export default function Page() {
...
}
return <button action={publish}>Publish</button>;
return <button onClick={publish}>Publish</button>;
}
```
```jsx filename="app/page.js" switcher
'use client'
export default function Page() {
const publishVersion = await getLatestVersion();
......@@ -944,7 +946,7 @@ export default function Page() {
...
}
return <button action={publish}>Publish</button>;
return <button onClick={publish}>Publish</button>;
}
```
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment