Skip to content

Commit 06a3347

Browse files
aurorascharffclaude
andcommitted
Polish Server Functions examples: consistent headings, reset wording, transition comment
- Convert the remaining two Usage headings to gerund form to match the rest of the page and react.dev convention (anchors unchanged) - Reset wording: "succeeds" + "the form's uncontrolled fields" (aligns with #8512) - Comment the startTransition-after-await; bump CodeStep line accordingly Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 623256a commit 06a3347

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/content/reference/rsc/server-functions.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export async function updateName(name) {
110110
}
111111
```
112112

113-
```js [[1, 4, "updateName"], [1, 14, "updateName"], [2, 12, "submitAction"], [2, 25, "submitAction"]]
113+
```js [[1, 4, "updateName"], [1, 14, "updateName"], [2, 12, "submitAction"], [2, 26, "submitAction"]]
114114
"use client";
115115

116116
import {useState, useTransition} from 'react';
@@ -125,6 +125,7 @@ function UpdateName() {
125125
function submitAction() {
126126
startTransition(async () => {
127127
const {error} = await updateName(name);
128+
// State updates after an await aren't automatically Transitions, so wrap them
128129
startTransition(() => {
129130
setError(error);
130131
if (!error) {
@@ -185,11 +186,11 @@ function UpdateName() {
185186
}
186187
```
187188

188-
When the Form Action completes, React will automatically reset the uncontrolled fields in the form. Server Function forms can be submitted before the JavaScript bundle loads. You can add `useActionState` to access the pending state and last response.
189+
When the Form Action succeeds, React will automatically reset the form's uncontrolled fields. Server Function forms can be submitted before the JavaScript bundle loads. You can add `useActionState` to access the pending state and last response.
189190

190191
For more, see the docs for [Server Functions in Forms](/reference/rsc/use-server#server-functions-in-forms).
191192

192-
### Server Functions with `useActionState` {/*server-functions-with-use-action-state*/}
193+
### Calling a Server Function with `useActionState` {/*server-functions-with-use-action-state*/}
193194

194195
You can call Server Functions with `useActionState` for the common case where you just need access to the action pending state and last returned response. The Server Function receives the previous state as its first argument and the submitted `FormData` as its second argument. Its return value becomes the next state:
195196

@@ -228,7 +229,7 @@ When using `useActionState` with a Server Function, the form can be submitted be
228229

229230
For more, see the docs for [`useActionState`](/reference/react/useActionState).
230231

231-
### Progressive enhancement with `useActionState` {/*progressive-enhancement-with-useactionstate*/}
232+
### Supporting progressive enhancement with `useActionState` {/*progressive-enhancement-with-useactionstate*/}
232233

233234
Server Functions also support progressive enhancement with the third argument of `useActionState`.
234235

0 commit comments

Comments
 (0)