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/hooks/useFormStatus.md
+33-33
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,13 @@ canary: true
5
5
6
6
<Canary>
7
7
8
-
The `useFormStatus`Hook is currently only available in React's Canary and experimental channels. Learn more about [React's release channels here](/community/versioning-policy#all-release-channels).
The `useFormStatus`Hook provides status information of the last form submission.
30
+
`useFormStatus`フックは、直近のフォーム送信に関するステータス情報を提供します。
31
31
32
32
```js {5},[[1, 6, "status.pending"]]
33
33
import { useFormStatus } from"react-dom";
@@ -47,42 +47,42 @@ export default App() {
47
47
}
48
48
```
49
49
50
-
To get status information, the `Submit`component must be rendered within a `<form>`. The Hook returns information like the <CodeStepstep={1}>`pending`</CodeStep> property which tells you if the form is actively submitting.
*`data`: An object implementing the [`FormData interface`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) that contains the data the parent `<form>`is submitting. If there is no active submission or no parent `<form>`, it will be `null`.
*`method`: A string value of either `'get'`or`'post'`. This represents whether the parent `<form>`is submitting with either a `GET`or`POST`[HTTP method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods). By default, a `<form>`will use the `GET`method and can be specified by the [`method`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#method)property.
[//]: #(Link to `<form>` documentation. "Read more on the `action` prop on `<form>`.")
71
-
*`action`: A reference to the function passed to the `action` prop on the parent `<form>`. If there is no parent`<form>`, the property is `null`. If there is a URI value provided to the `action`prop, or no`action`prop specified, `status.action`will be `null`.
*The `useFormStatus`Hook must be called from a component that is rendered inside a `<form>`.
76
-
*`useFormStatus`will only return status information for a parent `<form>`. It will not return status information for any `<form>`rendered in that same component or children components.
### Display a pending state during form submission {/*display-a-pending-state-during-form-submission*/}
83
-
To display a pending state while a form is submitting, you can call the `useFormStatus` Hook in a component rendered in a `<form>`and read the`pending`property returned.
Here, we use the `pending`property to indicate the form is submitting.
85
+
以下では、フォームが送信中であることを示すために `pending`プロパティを使用しています。
86
86
87
87
<Sandpack>
88
88
@@ -133,9 +133,9 @@ export async function submitForm(query) {
133
133
134
134
<Pitfall>
135
135
136
-
##### `useFormStatus`will not return status information for a `<form>`rendered in the same component. {/*useformstatus-will-not-return-status-information-for-a-form-rendered-in-the-same-component*/}
The `useFormStatus`Hook only returns status information for a parent `<form>`and not for any `<form>`rendered in the same component calling the Hook, or child components.
Here, we have a form where users can request a username. We can use `useFormStatus`to display a temporary status message confirming what username they have requested.
`useFormStatus`will only return status information for a parent `<form>`.
257
+
`useFormStatus`は親の `<form>` に対するステータス情報のみを返します。
258
258
259
-
If the component that calls `useFormStatus`is not nested in a `<form>`, `status.pending`will always return `false`. Verify `useFormStatus`is called in a component that is a child of a `<form>`element.
`useFormStatus`will not track the status of a `<form>`rendered in the same component. See [Pitfall](#useformstatus-will-not-return-status-information-for-a-form-rendered-in-the-same-component) for more details.
0 commit comments