Skip to content

Commit 5bc1d26

Browse files
authored
Add useFormState permalink arg (#6402)
1 parent e33ec30 commit 5bc1d26

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/content/reference/react-dom/hooks/useFormState.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The `useFormState` Hook is currently only available in React's Canary and experi
1414
`useFormState` is a Hook that allows you to update state based on the result of a form action.
1515

1616
```js
17-
const [state, formAction] = useFormState(fn, initialState);
17+
const [state, formAction] = useFormState(fn, initialState, permalink?);
1818
```
1919
2020
</Intro>
@@ -25,7 +25,7 @@ const [state, formAction] = useFormState(fn, initialState);
2525
2626
## Reference {/*reference*/}
2727
28-
### `useFormState(action, initialState)` {/*useformstate*/}
28+
### `useFormState(action, initialState, permalink?)` {/*useformstate*/}
2929
3030
{/* TODO T164397693: link to actions documentation once it exists */}
3131
@@ -59,6 +59,7 @@ If used with a Server Action, `useFormState` allows the server's response from s
5959
6060
* `fn`: The function to be called when the form is submitted or button pressed. When the function is called, it will receive the previous state of the form (initially the `initialState` that you pass, subsequently its previous return value) as its initial argument, followed by the arguments that a form action normally receives.
6161
* `initialState`: The value you want the state to be initially. It can be any serializable value. This argument is ignored after the action is first invoked.
62+
* **optional** `permalink`: A string containing the unique page URL that this form modifies. For use on pages with dynamic content (eg: feeds) in conjunction with progressive enhancement: if `fn` is a [server action](/reference/react/use-server) and the form is submitted before the JavaScript bundle loads, the browser will navigate to the specified permalink URL, rather than the current page's URL. Ensure that the same form component is rendered on the destination page (including the same action `fn` and `permalink`) so that React knows how to pass the state through. Once the form has been hydrated, this parameter has no effect.
6263
6364
{/* TODO T164397693: link to serializable values docs once it exists */}
6465

0 commit comments

Comments
 (0)