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
A progressively enhanced HTML [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) that submits data to actions via `fetch`, activating pending states in `useNavigation` which enables advanced user interfaces beyond a basic HTML form. After a form's action completes, all data on the page is automatically revalidated to keep the UI in sync with the data.
26
-
27
-
Because it uses the HTML form API, server rendered pages are interactive at a basic level before JavaScript loads. Instead of React Router managing the submission, the browser manages the submission as well as the pending states (like the spinning favicon). After JavaScript loads, React Router takes over enabling web application user experiences.
28
-
29
-
Form is most useful for submissions that should also change the URL or otherwise add an entry to the browser history stack. For forms that shouldn't manipulate the browser history stack, use [`<fetcher.Form>`][fetcher_form].
25
+
A progressively enhanced HTML [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)
26
+
that submits data to actions via [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API),
27
+
activating pending states in [`useNavigation`](../hooks/useNavigation) which enables advanced
28
+
user interfaces beyond a basic HTML [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form).
29
+
After a form's `action` completes, all data on the page is automatically
30
+
revalidated to keep the UI in sync with the data.
31
+
32
+
Because it uses the HTML form API, server rendered pages are interactive at a
33
+
basic level before JavaScript loads. Instead of React Router managing the
34
+
submission, the browser manages the submission as well as the pending states
35
+
(like the spinning favicon). After JavaScript loads, React Router takes over
36
+
enabling web application user experiences.
37
+
38
+
`Form` is most useful for submissions that should also change the URL or
39
+
otherwise add an entry to the browser history stack. For forms that shouldn't
40
+
manipulate the browser history stack, use [`<fetcher.Form>`][fetcher_form].
30
41
31
42
```tsx
32
43
import { Form } from"react-router";
@@ -45,7 +56,7 @@ function NewEvent() {
45
56
46
57
### action
47
58
48
-
The URL to submit the form data to. If `undefined`, this defaults to the
59
+
The URL to submit the form data to. If `undefined`, this defaults to the
49
60
closest route in context.
50
61
51
62
### discover
@@ -81,8 +92,9 @@ can pick up the fetcher's state in a different component in a [`useFetcher`](../
81
92
The HTTP verb to use when the form is submitted. Supports "get", "post",
82
93
"put", "delete", and "patch".
83
94
84
-
Native `<form>` only supports `get` and `post`, avoid the other verbs if
Statetopasstothenew[`Location`](https://api.reactrouter.com/v7/interfaces/react_router.Location.html) to store in [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state).
54
56
55
-
### relative
57
+
### to
56
58
57
-
Howtointerpretrelativeroutinginthe`to`prop. See [`RelativeRoutingType`](https://api.reactrouter.com/v7/types/react_router.RelativeRoutingType.html).
0 commit comments