Skip to content

Commit a732a9a

Browse files
authored
Merge pull request #608 from reactjs/copy/use-form-status
Translation of the useFormStatus page
2 parents d1ab799 + df5e3b7 commit a732a9a

File tree

2 files changed

+49
-45
lines changed

2 files changed

+49
-45
lines changed

TRANSLATORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Voici la liste par ordre alphabétique (prénom, nom). **🙏🏻 Mille mercis
103103
<li><a href="https://fr.react.dev/reference/react/use-client"><code>'use client'</code></a></li>
104104
<li><a href="https://fr.react.dev/reference/react/use-server"><code>'use server'</code></a></li>
105105
<li><a href="https://fr.react.dev/reference/react-dom/hooks">react-dom : Hooks</a> (accueil chapitre)</li>
106+
<li><a href="https://fr.react.dev/reference/react-dom/hooks/useFormStatus"><code>useFormStatus</code></a></li>
106107
<li><a href="https://fr.react.dev/reference/react-dom/components">react-dom : Composants</a> (accueil chapitre)</li>
107108
<li><a href="https://fr.react.dev/reference/react-dom/components/select"><code>&lt;select&gt;</code></a></li>
108109
<li><a href="https://fr.react.dev/reference/react-dom">API React DOM intégrées</a></li>

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

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ canary: true
55

66
<Canary>
77

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).
8+
Le Hook `useFormStatus` n'est actuellement disponible que sur les canaux de livraison Canary et Expérimental de React. Apprenez-en davantage sur [les canaux de livraison React](/community/versioning-policy#all-release-channels).
99

1010
</Canary>
1111

1212
<Intro>
1313

14-
`useFormStatus` is a Hook that gives you status information of the last form submission.
14+
`useFormStatus` est un Hook qui vous fournit des informations d'état sur le dernier envoi de formulaire parent.
1515

1616
```js
1717
const { pending, data, method, action } = useFormStatus();
@@ -23,19 +23,19 @@ const { pending, data, method, action } = useFormStatus();
2323

2424
---
2525

26-
## Reference {/*reference*/}
26+
## Référence {/*reference*/}
2727

2828
### `useFormStatus()` {/*use-form-status*/}
2929

30-
The `useFormStatus` Hook provides status information of the last form submission.
30+
Le Hook `useFormStatus` vous fournit des informations d'état sur le dernier envoi de formulaire parent.
3131

3232
```js {5},[[1, 6, "status.pending"]]
3333
import { useFormStatus } from "react-dom";
3434
import action from './actions';
3535

3636
function Submit() {
3737
const status = useFormStatus();
38-
return <button disabled={status.pending}>Submit</button>
38+
return <button disabled={status.pending}>Envoyer</button>
3939
}
4040

4141
export default App() {
@@ -47,42 +47,43 @@ export default App() {
4747
}
4848
```
4949

50-
To get status information, the `Submit` component must be rendered within a `<form>`. The Hook returns information like the <CodeStep step={1}>`pending`</CodeStep> property which tells you if the form is actively submitting.
50+
Pour récupérer les informations d'état, le composant `Submit` doit être utilisé au sein d'un `<form>`. Le Hook renvoie des informations telles que la propriété <CodeStep step={1}>`pending`</CodeStep>, qui vous indique si le formulaire est en cours d'envoi.
5151

52-
In the above example, `Submit` uses this information to disable `<button>` presses while the form is submitting.
52+
Dans l'exemple ci-dessus, `Submit` utilise cette information pour désactiver l'interactivité du `<button>` pendant l'envoi du formulaire.
5353

54-
[See more examples below.](#usage)
54+
[Voir plus d'exemples ci-dessous](#usage).
5555

56-
#### Parameters {/*parameters*/}
56+
#### Paramètres {/*parameters*/}
5757

58-
`useFormStatus` does not take any parameters.
58+
`useFormStatus` ne prend aucun paramètre.
5959

60-
#### Returns {/*returns*/}
60+
#### Valeur renvoyée {/*returns*/}
6161

62-
A `status` object with the following properties:
62+
Un objet `status` doté des propriétés suivantes :
6363

64-
* `pending`: A boolean. If `true`, this means the parent `<form>` is pending submission. Otherwise, `false`.
64+
* `pending` : un booléen. Vaut `true` si le `<form>` parent est en cours d'envoi, sinon `false`.
6565

66-
* `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`.
66+
* `data` : un objet qui implémente [l'interface `FormData`](https://developer.mozilla.org/docs/Web/API/FormData), contenant les données que le `<form>` parent est en train d'envoyer. Si aucun envoi n'est en cours, ou s'il n'y a pas de `<form>` parent, cette propriété vaut `null`.
6767

68-
* `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.
68+
* `method` : une chaîne de caractères valant soit `'get'`, soit `'post'`, selon que le `<form>` parent est en train de faire un envoi avec une [méthode HTTP](https://developer.mozilla.org/docs/Web/HTTP/Methods) `GET` ou `POST`. Par défaut, un `<form>` utilisera la méthode `GET`, mais ça peut être spécifié par l'attribut [`method`](https://developer.mozilla.org/docs/Web/HTML/Element/form#method).
6969

7070
[//]: # (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`.
71+
* `action` : une référence vers la fonction passée à la prop `action` du `<form>` parent. S'il n'y a pas de `<form>` parent, cette propriété vaut `null`. Si la prop `action` a reçu une valeur URI, ou si aucune prop `action` n'est spécifiée, cette propriété vaut `null`.
7272

73-
#### Caveats {/*caveats*/}
73+
#### Limitations {/*caveats*/}
7474

75-
* 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.
75+
* Le Hook `useFormStatus` doit être appelé dans un composant dont le rendu a lieu au sein d'un `<form>`.
76+
* `useFormStatus` ne renverra que les informations d'état du `<form>` parent. Il ne renverra pas les informations de statut d'un `<form>` placé dans le rendu du composant courant ou de ses composants enfants.
7777

7878
---
7979

80-
## Usage {/*usage*/}
80+
## Utilisation {/*usage*/}
8181

82-
### 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.
82+
### Afficher un état d'attente pendant l'envoi du formulaire {/*display-a-pending-state-during-form-submission*/}
8483

85-
Here, we use the `pending` property to indicate the form is submitting.
84+
Pour afficher un état d'attente pendant que le formulaire est en cours d'envoi, vous pouvez utilisez le Hook `useFormStatus` dans un composant au sein du `<form>` et lire la propriété `pending` qu'il renvoie.
85+
86+
Nous utilisons ci-dessous la propriété `pending` pour indiquer que le formulaire est en cours d'envoi.
8687

8788
<Sandpack>
8889

@@ -94,7 +95,7 @@ function Submit() {
9495
const { pending } = useFormStatus();
9596
return (
9697
<button type="submit" disabled={pending}>
97-
{pending ? "Submitting..." : "Submit"}
98+
{pending ? "Envoi en cours..." : "Envoyer"}
9899
</button>
99100
);
100101
}
@@ -129,34 +130,36 @@ export async function submitForm(query) {
129130
"devDependencies": {}
130131
}
131132
```
132-
</Sandpack>
133+
</Sandpack>
133134

134135
<Pitfall>
135136

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*/}
137+
#### `useFormStatus` ne renverra pas d'information d'état pour un `<form>` situé dans le même composant. {/*useformstatus-will-not-return-status-information-for-a-form-rendered-in-the-same-component*/}
137138

138-
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.
139+
Le Hook `useFormStatus` ne renvoie que les informations d'état du `<form>` parent, et non celles d'un `<form>` placé dans le rendu du composant appelant le Hook ou dans ses composants enfants.
139140

140141
```js
141142
function Form() {
142-
// 🚩 `pending` will never be true
143-
// useFormStatus does not track the form rendered in this component
143+
// 🚩 `pending` ne sera jamais `true`
144+
// useFormStatus ne surveille pas le formulaire situé dans le
145+
// rendu de ce composant
144146
const { pending } = useFormStatus();
145147
return <form action={submit}></form>;
146148
}
147149
```
148150

149-
Instead call `useFormStatus` from inside a component that is located inside `<form>`.
151+
Appelez plutôt `useFormStatus` depuis un composant imbriqué dans `<form>`.
150152

151153
```js
152154
function Submit() {
153-
// ✅ `pending` will be derived from the form that wraps the Submit component
154-
const { pending } = useFormStatus();
155+
// ✅ `pending` se basera sur le formulaire qui enrobe
156+
// le composant Submit
157+
const { pending } = useFormStatus();
155158
return <button disabled={pending}>...</button>;
156159
}
157160

158161
function Form() {
159-
// This is the <form> `useFormStatus` tracks
162+
// Voici le <form> surveillé par `useFormStatus`
160163
return (
161164
<form action={submit}>
162165
<Submit />
@@ -167,11 +170,11 @@ function Form() {
167170

168171
</Pitfall>
169172

170-
### Read the form data being submitted {/*read-form-data-being-submitted*/}
173+
### Lire les données en cours d'envoi {/*read-form-data-being-submitted*/}
171174

172-
You can use the `data` property of the status information returned from `useFormStatus` to display what data is being submitted by the user.
175+
Vous pouvez utiliser la propriété `data` des informations d'état renvoyées par `useFormStatus` pour afficher les données que l'utilisateur est en train d'envoyer.
173176

174-
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.
177+
Dans l'exemple ci-dessous, nous avons un formulaire permettant à l'utilisateur de réserver un identifiant. Nous pouvons y utiliser `useFormStatus` pour afficher un message temporaire confirmant l'identifiant demandé.
175178

176179
<Sandpack>
177180

@@ -203,13 +206,13 @@ export default function UsernameForm() {
203206

204207
return (
205208
<>
206-
<label>Request a Username: </label><br />
209+
<label>Réserver l’identifiant : </label><br />
207210
<input type="text" name="username" />
208211
<button type="submit" disabled={pending}>
209-
{pending ? 'Submitting...' : 'Submit'}
212+
{pending ? 'Envoi en cours...' : 'Envoyer'}
210213
</button>
211214
{showSubmitted ? (
212-
<p>Submitted request for username: {submittedUsername.current}</p>
215+
<p>Demande en cours pour l’identifiant : {submittedUsername.current}</p>
213216
) : null}
214217
</>
215218
);
@@ -246,16 +249,16 @@ export async function submitForm(query) {
246249
"devDependencies": {}
247250
}
248251
```
249-
</Sandpack>
252+
</Sandpack>
250253
251254
---
252255
253-
## Troubleshooting {/*troubleshooting*/}
256+
## Dépannage {/*troubleshooting*/}
254257
255-
### `status.pending` is never `true` {/*pending-is-never-true*/}
258+
### `status.pending` ne vaut jamais `true` {/*pending-is-never-true*/}
256259
257-
`useFormStatus` will only return status information for a parent `<form>`.
260+
`useFormStatus` ne renvoie d'informations d'état que pour un `<form>` parent.
258261
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.
262+
Si le composant qui appelle `useFormStatus` n'est pas imbriqué dans un `<form>`, `status.pending` vaudra toujours `false`. Vérifiez que `useFormStatus` est appelé depuis un composant qui figure à l'intérieur d'un élément `<form>`.
260263
261-
`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.
264+
`useFormStatus` ne surveillera pas l'état d'un `<form>` situé dans le rendu du même composant. Consultez le [Piège](#useformstatus-will-not-return-status-information-for-a-form-rendered-in-the-same-component) pour en savoir plus.

0 commit comments

Comments
 (0)