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: docs/components/form.md
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -215,6 +215,24 @@ See also:
215
215
-[`useActionData`][useactiondata]
216
216
-[`useSubmit`][usesubmit]
217
217
218
+
## `state`
219
+
220
+
The `state` property can be used to set a stateful value for the new location which is stored inside [history state][history-state]. This value can subsequently be accessed via `useLocation()`.
221
+
222
+
```tsx
223
+
<Form
224
+
method="post"
225
+
action="new-path"
226
+
state={{ some: "value" }}
227
+
/>
228
+
```
229
+
230
+
You can access this state value while on the "new-path" route:
231
+
232
+
```ts
233
+
let { state } =useLocation();
234
+
```
235
+
218
236
## `preventScrollReset`
219
237
220
238
If you are using [`<ScrollRestoration>`][scrollrestoration], this lets you prevent the scroll position from being reset to the top of the window when the form action redirects to a new location.
@@ -330,3 +348,4 @@ You can access those values from the `request.url`
Copy file name to clipboardExpand all lines: docs/hooks/use-submit.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -150,4 +150,7 @@ submit(null, {
150
150
<Formaction="/logout"method="post" />;
151
151
```
152
152
153
+
Because submissions are navigations, the options may also contain the other navigation related props from [`<Form>`][form] such as `replace`, `state`, `preventScrollReset`, `relative`, etc.
0 commit comments