Skip to content

Commit 1f748fd

Browse files
committed
Fix Server Function signature and two typos in 'use server' reference
requestUsername is passed to useActionState but declared as requestUsername(formData). useActionState calls the action with the previous state as the first argument, so formData ends up null and formData.get('username') throws. The useActionState reference already covers this under "My Action cannot read form data". Also drop a stray semicolon in the LikeButton example, where it sits in the fragment's children and renders as text, and remove a duplicated word in the RSC banner so it matches use-client.md.
1 parent 8efce78 commit 1f748fd

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/content/reference/rsc/use-server.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ titleForTitleTag: "'use server' directive"
55

66
<RSC>
77

8-
`'use server'` is for use with [using React Server Components](/reference/rsc/server-components).
8+
`'use server'` is for use with [React Server Components](/reference/rsc/server-components).
99

1010
</RSC>
1111

@@ -139,7 +139,7 @@ To update the UI based on the result of a Server Function while supporting progr
139139
// requestUsername.js
140140
'use server';
141141

142-
export default async function requestUsername(formData) {
142+
export default async function requestUsername(prevState, formData) {
143143
const username = formData.get('username');
144144
if (canRequest(username)) {
145145
// ...
@@ -199,7 +199,7 @@ function LikeButton() {
199199
return (
200200
<>
201201
<p>Total Likes: {likeCount}</p>
202-
<button onClick={onClick} disabled={isPending}>Like</button>;
202+
<button onClick={onClick} disabled={isPending}>Like</button>
203203
</>
204204
);
205205
}

0 commit comments

Comments
 (0)