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/rsc/directives.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,13 @@ canary: true
5
5
6
6
<Canary>
7
7
8
-
Ces directives ne sont utiles que si vous [utilisez React Server Components](/learn/start-a-new-react-project#bleeding-edge-react-frameworks) ou créez une bibliothèque compatible avec eux.
8
+
Ces directives ne sont utiles que si vous [utilisez les Composants Serveur](/learn/start-a-new-react-project#bleeding-edge-react-frameworks) ou créez une bibliothèque compatible avec eux.
9
9
10
10
</Canary>
11
11
12
12
<Intro>
13
13
14
-
Les directives fournissent des instructions à destination des [*bundlers* compatibles avec React Server Components](/learn/start-a-new-react-project#bleeding-edge-react-frameworks).
14
+
Les directives fournissent des instructions à destination des [*bundlers* compatibles avec les Composants Serveur](/learn/start-a-new-react-project#bleeding-edge-react-frameworks).
Copy file name to clipboardExpand all lines: src/content/reference/rsc/server-actions.md
+38-40Lines changed: 38 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,43 +1,41 @@
1
1
---
2
-
title: Server Actions
2
+
title: Actions Serveur
3
3
canary: true
4
4
---
5
5
6
-
{/* FIXME:L10N*/}
7
-
8
6
<Intro>
9
7
10
-
Server Actions allow Client Components to call async functions executed on the server.
8
+
Les Actions Serveur permettent aux Composants Client d'appeler des fonctions asynchrones exécutées côté serveur.
11
9
12
10
</Intro>
13
11
14
12
<InlineToc />
15
13
16
14
<Note>
17
15
18
-
#### How do I build support for Server Actions? {/*how-do-i-build-support-for-server-actions*/}
16
+
#### Comment prendre en charge les Actions Serveur ? {/*how-do-i-build-support-for-server-actions*/}
19
17
20
-
While Server Actions in React 19 are stable and will not break between major versions, the underlying APIs used to implement Server Actions in a React Server Components bundler or framework do not follow semver and may break between minors in React 19.x.
18
+
Même si les Actions Serveur dans React 19 sont stables et ne casseront pas la compatibilité entre les versions majeures, les API sous-jacentes utilisées pour implémenter les Actions Serveur au sein d'un *bundler* ou framework compatible avec les React Server Components ne suivent pas, elles, le versionnage sémantique et sont susceptibles de casser la compatibilité entre les versions mineures de React 19.x.
21
19
22
-
To support Server Actions as a bundler or framework, we recommend pinning to a specific React version, or using the Canary release. We will continue working with bundlers and frameworks to stabilize the APIs used to implement Server Actions in the future.
20
+
Pour prendre en charge les Actions Serveur dans un *bundler* ou framework, nous vous conseillons de figer React sur une version spécifique, ou d'utiliser une version Canari. Nous allons continuer à collaborer avec les *bundlers* et frameworks pour stabiliser les API utilisées pour implémenter les Actions Serveur à l'avenir.
23
21
24
22
</Note>
25
23
26
-
When a Server Action is defined with the `"use server"` directive, your framework will automatically create a reference to the server function, and pass that reference to the Client Component. When that function is called on the client, React will send a request to the server to execute the function, and return the result.
24
+
Lorsqu'une Action Serveur est définie au moyen d'une directive `"use server"`, votre framework crée automatiquement une référence à la fonction serveur, et la passe au Composant Client. Lorsque cette fonction sera appelée côté client, React réagira en envoyant une requête au serveur pour exécuter cette fonction, et en renvoyant le résultat.
27
25
28
-
Server Actions can be created in Server Components and passed as props to Client Components, or they can be imported and used in Client Components.
26
+
Les Actions Serveur peuvent être créées dans les Composants Serveur et passées comme props à des Composants Client, ou peuvent être directement importées et utilisées dans des Composants Client.
29
27
30
-
### Creating a Server Action from a Server Component {/*creating-a-server-action-from-a-server-component*/}
28
+
### Créer une Action Serveur à partir d'un Composant Serveur {/*creating-a-server-action-from-a-server-component*/}
31
29
32
-
Server Components can define Server Actions with the `"use server"` directive:
30
+
Les Composants Serveur peuvent définir des Actions Serveur au moyen de la directive `"use server"`:
When React renders the `EmptyNote` Server Component, it will create a reference to the`createNoteAction`function, and pass that reference to the`Button` Client Component. When the button is clicked, React will send a request to the server to execute the `createNoteAction`function with the reference provided:
48
+
Lorsque React affichera le Composant Serveur `EmptyNote`, il créera une référence à la fonction`createNoteAction`et passera cette référence au Composant Client`Button`. Lorsqu'on cliquera sur le bouton, React enverra la requête au serveur pour exécuter la fonction `createNoteAction`avec la référence fournie :
return<button onClick={() =>onClick()}>Créer une note vide</button>
59
57
}
60
58
```
61
59
62
-
For more, see the docs for[`"use server"`](/reference/rsc/use-server).
60
+
Pour en savoir plus, consultez la documentation de[`"use server"`](/reference/rsc/use-server).
63
61
64
62
65
-
### Importing Server Actions from Client Components {/*importing-server-actions-from-client-components*/}
63
+
### Importer des Actions Serveur depuis des Composants Client {/*importing-server-actions-from-client-components*/}
66
64
67
-
Client Components can import Server Actions from files that use the `"use server"` directive:
65
+
Les Composants Client peuvent importer des Actions Serveur depuis des modules utilisant la directive `"use server"`:
68
66
69
67
```js [[1, 3, "createNoteAction"]]
70
68
"use server";
@@ -75,7 +73,7 @@ export async function createNoteAction() {
75
73
76
74
```
77
75
78
-
When the bundler builds the `EmptyNote` Client Component, it will create a reference to the `createNoteAction` function in the bundle. When the `button` is clicked, React will send a request to the server to execute the `createNoteAction`function using the reference provided:
76
+
Lorsque le *bundler* construit le Composant Client `EmptyNote`, il injecte dans le *bundle* une référence à la fonction `createNoteAction`. Lorsqu'on cliquera sur le `button`, React enverra une requête au serveur pour exécuter la fonction `createNoteAction`au moyen de la référence fournie :
When the Form submission succeeds, React will automatically reset the form. You can add`useActionState`to access the pending state, last response, or to support progressive enhancement.
162
+
Lorsque l'envoi du formulaire aura réussi, React réinitialisera automatiquement le formulaire. Vous pouvez ajouter`useActionState`pour accéder à l'état d'attente, consulter la dernière réponse connue, ou prendre en charge l'amélioration progressive.
165
163
166
-
For more, see the docs for [Server Actions in Forms](/reference/rsc/use-server#server-actions-in-forms).
164
+
Pour en savoir plus, allez lire [Les Actions Serveur dans les formulaires](/reference/rsc/use-server#server-actions-in-forms).
167
165
168
-
### Server Actions with`useActionState` {/*server-actions-with-use-action-state*/}
You can compose Server Actions with `useActionState`for the common case where you just need access to the action pending state and last returned response:
168
+
Vous pouvez composer des Actions Serveur avec `useActionState`pour le cas classique où vous avez juste besoin d'accéder à l'état en attente de l'action et à sa dernière réponse connue :
When using `useActionState`with Server Actions, React will also automatically replay form submissions entered before hydration finishes. This means users can interact with your app even before the app has hydrated.
187
+
Lorsque vous utilisez `useActionState`avec des Actions Serveur, React rejoue automatiquement les envois de formulaire réalisés avant la fin de l'hydratation. Ça signifie que les utilisateurs peuvent interagir avec votre appli avant même qu'elle soit hydratée.
190
188
191
-
For more, see the docs for[`useActionState`](/reference/react-dom/hooks/useFormState).
189
+
Pour en savoir plus, consultez la documentation de[`useActionState`](/reference/react-dom/hooks/useFormState).
When the <CodeStepstep={2}>permalink</CodeStep> is provided to`useActionState`, React will redirect to the provided URL if the form is submitted before the JavaScript bundle loads.
211
+
Lorsqu'un <CodeStepstep={2}>permalien</CodeStep> est fourni à`useActionState`, React redirigera sur l'URL fournie si le formulaire est envoyé avant que le *bundle* JavaScript soit chargé.
214
212
215
-
For more, see the docs for[`useActionState`](/reference/react-dom/hooks/useFormState).
213
+
Apprenez-en davantage dans la documentation de[`useActionState`](/reference/react-dom/hooks/useFormState).
0 commit comments