You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/reference/react-dom/components/form.md
+7-8Lines changed: 7 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -167,11 +167,11 @@ When `<form>` is rendered by a [Server Component](/reference/rsc/use-client), an
167
167
168
168
### Preserving form values after submission {/*preserve-form-values-after-submission*/}
169
169
170
-
The browser clears a form's input state on submit. A URL `action`follows this same behavior. React does the same when `action` is a function, so your form works consistently before and after JavaScript loads.
170
+
By default, the browser clears a form's input state after submission. Forms with a URL `action`follow this behavior, and React mirrors it when `action` is a function-ensuring your form behaves consistently both before and after JavaScript loads.
171
171
172
-
When you pass a function to `action` or `formAction`, React resets the form's [uncontrolled fields](/reference/react-dom/components/input#reading-the-input-values-when-submitting-a-form) after the action succeeds. The reset only applies to uncontrolled fields, so [inputs you control with state](/reference/react-dom/components/input#controlling-an-input-with-a-state-variable) are never cleared.
172
+
When you pass a function to `action` or `formAction`, React resets the form's [uncontrolled fields](/reference/react-dom/components/input#reading-the-input-values-when-submitting-a-form) after the action succeeds. This reset only affects uncontrolled fields—[inputs controlled with state](/reference/react-dom/components/input#controlling-an-input-with-a-state-variable) are never cleared.
173
173
174
-
To keep the values of uncontrolled fields, add an `onSubmit` handler that calls `e.preventDefault()` and runs the action inside a [Transition](/reference/react/useTransition). Keep the `action` prop on the form so it still works before JavaScript loads.
174
+
To preserve the values of uncontrolled fields after submission, add an `onSubmit` handler that calls `e.preventDefault()` and runs the action inside a [Transition](/reference/react/useTransition). Keep the `action` prop on the form so it continues to work before JavaScript loads.
175
175
176
176
<Sandpack>
177
177
@@ -210,8 +210,6 @@ export async function submitForm(formData) {
210
210
211
211
</Sandpack>
212
212
213
-
Because you call the action manually from `onSubmit`, [`useFormStatus`](/reference/react-dom/hooks/useFormStatus) won't report its pending state. Read `isPending` from the same [`useTransition`](/reference/react/useTransition) call instead.
214
-
215
213
<DeepDive>
216
214
217
215
#### Resetting only some fields, or resetting on the server {/*resetting-only-some-fields*/}
@@ -228,11 +226,12 @@ import { submitForm } from "./actions.js";
228
226
229
227
functionEditForm() {
230
228
// The action returns { submitted: formData, error } on failure
0 commit comments