Skip to content

Commit 5cf3c9e

Browse files
committed
copy(blog/react18-upgrade): translate up to TypeScript defs
1 parent 25def7e commit 5cf3c9e

4 files changed

Lines changed: 66 additions & 55 deletions

File tree

TRANSLATORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ Voici la liste par ordre alphabétique (prénom, nom). **🙏🏻 Mille mercis
135135
<li><a href="https://fr.react.dev/blog/2023/03/16/introducing-react-dev">Blog : Découvrez react.dev</a></li>
136136
<li><a href="https://fr.react.dev/blog/2022/06/15/react-labs-what-we-have-been-working-on-june-2022">Blog : React Labs juin 2022</a></li>
137137
<li><a href="https://fr.react.dev/blog/2022/03/29/react-v18">Blog : React v18.0</a></li>
138+
<li><a href="https://fr.react.dev/blog/2022/03/08/react-18-upgrade-guide">Blog : Comment migrer sur React 18</a></li>
138139
<li><a href="https://fr.react.dev/warnings/invalid-aria-prop">Avertissement : prop ARIA invalide</a></li>
139140
<li><a href="https://fr.react.dev/warnings/invalid-hook-call-warning">Avertissement : règles des Hooks</a></li>
140141
<li><a href="https://fr.react.dev/warnings/special-props">Avertissement : props à traitement spécial</a></li>

src/content/blog/2022/03/08/react-18-upgrade-guide.md

Lines changed: 59 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,91 @@
11
---
2-
title: "How to Upgrade to React 18"
2+
title: "Comment migrer sur React 18"
33
---
44

5-
March 08, 2022 by [Rick Hanlon](https://twitter.com/rickhanlonii)
5+
Le 8 mars 2022 par [Rick Hanlon](https://twitter.com/rickhanlonii)
66

77
---
88

99
<Intro>
1010

11-
As we shared in the [release post](/blog/2022/03/29/react-v18), React 18 introduces features powered by our new concurrent renderer, with a gradual adoption strategy for existing applications. In this post, we will guide you through the steps for upgrading to React 18.
11+
Comme nous l'avons annoncé dans le [billet de sortie](/blog/2022/03/29/react-v18), React 18 introduit des fonctionnalités basées sur notre nouveau moteur de rendu concurrent, avec une statégie d'adoption graduelle pour les applications existantes. Dans ce billet, nous vous guidons étape par étape dans votre migration sur React 18.
1212

13-
Please [report any issues](https://github.com/facebook/react/issues/new/choose) you encounter while upgrading to React 18.
13+
Merci de nous [signaler tout problème](https://github.com/facebook/react/issues/new/choose) que vous rencontreriez en migrant sur React 18.
1414

1515
</Intro>
1616

1717
<Note>
1818

19-
For React Native users, React 18 will ship in a future version of React Native. This is because React 18 relies on the New React Native Architecture to benefit from the new capabilities presented in this blogpost. For more information, see the [React Conf keynote here](https://www.youtube.com/watch?v=FZ0cG47msEk&t=1530s).
19+
Concernant les utilisateurs de React Native, React 18 sera livré dans une future version de React Native. C'est parce que React 18 repose sur la nouvelle architecture de React Native pour mettre en œuvre les nouvelles fonctionnalités présentées dans ce billet. Pour plus d'informations, regardez la [plénière d'ouverture de la React Conf](https://www.youtube.com/watch?v=FZ0cG47msEk&t=1530s).
2020

2121
</Note>
2222

2323
---
2424

25-
## Installing {/*installing*/}
25+
## Installation {/*installing*/}
2626

27-
To install the latest version of React:
27+
Pour installer la dernière version de React, faites :
2828

2929
```bash
3030
npm install react react-dom
3131
```
3232

33-
Or if you’re using yarn:
33+
Ou si vous utilisez Yarn :
3434

3535
```bash
3636
yarn add react react-dom
3737
```
3838

39-
## Updates to Client Rendering APIs {/*updates-to-client-rendering-apis*/}
39+
## Évolutions des API de rendu côté client {/*updates-to-client-rendering-apis*/}
4040

41-
When you first install React 18, you will see a warning in the console:
41+
Lorsque vous installez React &_ pour la première fois, vous verrez cet avertissement dans la console :
4242

4343
<ConsoleBlock level="error">
4444

4545
ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot
4646

4747
</ConsoleBlock>
4848

49-
React 18 introduces a new root API which provides better ergonomics for managing roots. The new root API also enables the new concurrent renderer, which allows you to opt-into concurrent features.
49+
*(« ReactDOM.render n'est plus pris en charge dans React 18. Utilisez plutôt createRoot. Tant que vous ne basculerez pas vers la nouvelle API, votre appli se comportera comme si elle utilisait React 17. Apprenez-en davantage ici : https://reactjs.org/link/switch-to-createroot », NdT)*
50+
51+
React 18 propose une nouvelle API avec une bien meilleure ergonomie pour gérer les racines applicatives. Cette nouvelle API permet également le recours au nouveau moteur de rendu concurrent, et donc aux fonctionnalités concurrentes.
5052

5153
```js
52-
// Before
54+
// Avant
5355
import { render } from 'react-dom';
5456
const container = document.getElementById('app');
5557
render(<App tab="home" />, container);
5658

57-
// After
59+
// Après
5860
import { createRoot } from 'react-dom/client';
5961
const container = document.getElementById('app');
60-
const root = createRoot(container); // createRoot(container!) if you use TypeScript
62+
const root = createRoot(container); // createRoot(container!) si vous utilisez TypeScript
6163
root.render(<App tab="home" />);
6264
```
6365

64-
We’ve also changed `unmountComponentAtNode` to `root.unmount`:
66+
Nous passons aussi de `unmountComponentAtNode` à `root.unmount` :
6567

6668
```js
67-
// Before
69+
// Avant
6870
unmountComponentAtNode(container);
6971

70-
// After
72+
// Après
7173
root.unmount();
7274
```
7375

74-
We've also removed the callback from render, since it usually does not have the expected result when using Suspense:
76+
La fonction de rappel de `render` a également disparu, dans la mesure où elle n'a généralement pas le résultat attendu lorsqu'on utilise Suspense :
7577

7678
```js
77-
// Before
79+
// Avant
7880
const container = document.getElementById('app');
7981
render(<App tab="home" />, container, () => {
80-
console.log('rendered');
82+
console.log('rendu effectué');
8183
});
8284

83-
// After
85+
// Après
8486
function AppWithCallbackAfterRender() {
8587
useEffect(() => {
86-
console.log('rendered');
88+
console.log('rendu effectué');
8789
});
8890

8991
return <App tab="home" />
@@ -96,57 +98,62 @@ root.render(<AppWithCallbackAfterRender />);
9698

9799
<Note>
98100

99-
There is no one-to-one replacement for the old render callback API — it depends on your use case. See the working group post for [Replacing render with createRoot](https://github.com/reactwg/react-18/discussions/5) for more information.
101+
Il n'y a pas d'alternative exacte à l'ancienne fonction de rappel de l'API de rendu racine ; tout dépend de votre cas d'utilisation. Consultez la discussion du groupe de travail sur [le remplacement de `render` par `createRoot`](https://github.com/reactwg/react-18/discussions/5) pour en apprendre davantage.
100102

101103
</Note>
102104

103-
Finally, if your app uses server-side rendering with hydration, upgrade `hydrate` to `hydrateRoot`:
105+
Pour finir, si votre appli utilise le rendu côté serveur avec l'hydratation, remplacez `hydrate` par `hydrateRoot` :
104106

105107
```js
106-
// Before
108+
// Avant
107109
import { hydrate } from 'react-dom';
108110
const container = document.getElementById('app');
109111
hydrate(<App tab="home" />, container);
110112

111-
// After
113+
// Après
112114
import { hydrateRoot } from 'react-dom/client';
113115
const container = document.getElementById('app');
114116
const root = hydrateRoot(container, <App tab="home" />);
115-
// Unlike with createRoot, you don't need a separate root.render() call here.
117+
// Contrairement à createRoot, vous n’avez ici pas besoin d’un appel
118+
// distinct à root.render()
116119
```
117120

118-
For more information, see the [working group discussion here](https://github.com/reactwg/react-18/discussions/5).
121+
Pour en apprendre davantage, consultez [cette discussion du groupe de travail](https://github.com/reactwg/react-18/discussions/5).
119122

120123
<Note>
121124

122-
**If your app doesn't work after upgrading, check whether it's wrapped in `<StrictMode>`.** [Strict Mode has gotten stricter in React 18](#updates-to-strict-mode), and not all your components may be resilient to the new checks it adds in development mode. If removing Strict Mode fixes your app, you can remove it during the upgrade, and then add it back (either at the top or for a part of the tree) after you fix the issues that it's pointing out.
125+
**Si votre appli ne fonctionne plus après la migration, vérifiez si elle est enrobée par `<StrictMode>`.** [Le mode strict est plus strict en React 18](#updates-to-strict-mode), et tous vos composants ne sont pas forcément conformes aux nouvelles vérifications qu'il effectue en mode développement. Si le retrait du mode strict fait refonctionner votre appli, vous pouvez le retirer pendant la migration puis le rajouter à la fin (soit à la racine soit sur une partie de l'arbre), après que vous aurez corrigé les problèmes qu'il met en lumière.
123126

124127
</Note>
125128

126-
## Updates to Server Rendering APIs {/*updates-to-server-rendering-apis*/}
129+
## Évolutions des API de rendu côté serveur {/*updates-to-server-rendering-apis*/}
130+
131+
Cette version a repensé les API de `react-dom/server` pour prendre pleinement en charge Suspense côté serveur, ainsi que le rendu streamé côté serveur. Dans ce cadre, nous déprécions l'ancienne API de streaming basée Node, qui ne permettait pas un streaming incrémental côté serveur grâce à Suspense.
132+
133+
Le recours à cette ancienne API entraînera un avertissement :
134+
135+
* `renderToNodeStream` : **déprécié ⛔️️**
136+
137+
Pour des environnements de streaming basés Node, utilisez plutôt :
127138

128-
In this release, we’re revamping our `react-dom/server` APIs to fully support Suspense on the server and Streaming SSR. As part of these changes, we're deprecating the old Node streaming API, which does not support incremental Suspense streaming on the server.
139+
* `renderToPipeableStream` : **nouveau ✨**
129140

130-
Using this API will now warn:
141+
Nous avons aussi ajouté une nouvelle API permettant le rendu streamé côté serveur avec Suspense pour les moteurs JavaScript plus modernes, tels que Deno ou les Cloudflare Workers :
131142

132-
* `renderToNodeStream`: **Deprecated ⛔️️**
143+
* `renderToReadableStream` : **nouveau ✨**
133144

134-
Instead, for streaming in Node environments, use:
135-
* `renderToPipeableStream`: **New ✨**
145+
Les API suivantes continuent de fonctionner, mais ne prennent que partiellement Suspense en charge :
136146

137-
We're also introducing a new API to support streaming SSR with Suspense for modern edge runtime environments, such as Deno and Cloudflare workers:
138-
* `renderToReadableStream`: **New ✨**
147+
* `renderToString` : **limité** ⚠️
148+
* `renderToStaticMarkup` : **limité** ⚠️
139149

140-
The following APIs will continue working, but with limited support for Suspense:
141-
* `renderToString`: **Limited** ⚠️
142-
* `renderToStaticMarkup`: **Limited** ⚠️
150+
Enfin, cette API continuera à fonctionner pour par exemple produire des e-mails :
143151

144-
Finally, this API will continue to work for rendering e-mails:
145152
* `renderToStaticNodeStream`
146153

147-
For more information on the changes to server rendering APIs, see the working group post on [Upgrading to React 18 on the server](https://github.com/reactwg/react-18/discussions/22), a [deep dive on the new Suspense SSR Architecture](https://github.com/reactwg/react-18/discussions/37), and [Shaundai Person’s](https://twitter.com/shaundai) talk on [Streaming Server Rendering with Suspense](https://www.youtube.com/watch?v=pj5N-Khihgc) at React Conf 2021.
154+
Pour de plus amples informations sur les évolutions des API de rendu côté serveur, consultez la discussion du groupe de travail sur [la migration sur React 18 côté serveur](https://github.com/reactwg/react-18/discussions/22), une [exploration en profondeur de la nouvelle architecture de SSR avec Suspense](https://github.com/reactwg/react-18/discussions/37), et la présentation de [Shaundai Person](https://twitter.com/shaundai) sur le [rendu streamé côté serveur avec Suspense](https://www.youtube.com/watch?v=pj5N-Khihgc) à la React Conf 2021.
148155

149-
## Updates to TypeScript definitions {/*updates-to-typescript-definitions*/}
156+
## Évolutions des définitions TypeScript {/*updates-to-typescript-definitions*/}
150157

151158
If your project uses TypeScript, you will need to update your `@types/react` and `@types/react-dom` dependencies to the latest versions. The new types are safer and catch issues that used to be ignored by the type checker. The most notable change is that the `children` prop now needs to be listed explicitly when defining props, for example:
152159

@@ -161,7 +168,7 @@ See the [React 18 typings pull request](https://github.com/DefinitelyTyped/Defin
161168

162169
If you find a bug in the typings, please [file an issue](https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/new?category=issues-with-a-types-package) in the DefinitelyTyped repo.
163170

164-
## Automatic Batching {/*automatic-batching*/}
171+
## Traitement par lots automatique {/*automatic-batching*/}
165172

166173
React 18 adds out-of-the-box performance improvements by doing more batching by default. Batching is when React groups multiple state updates into a single re-render for better performance. Before React 18, we only batched updates inside React event handlers. Updates inside of promises, setTimeout, native event handlers, or any other event were not batched in React by default:
167174

@@ -220,7 +227,7 @@ function handleClick() {
220227

221228
For more information, see the [Automatic batching deep dive](https://github.com/reactwg/react-18/discussions/21).
222229

223-
## New APIs for Libraries {/*new-apis-for-libraries*/}
230+
## Nouvelles API à destination des bibliothèques {/*new-apis-for-libraries*/}
224231

225232
In the React 18 Working Group we worked with library maintainers to create new APIs needed to support concurrent rendering for use cases specific to their use case in areas like styles, and external stores. To support React 18, some libraries may need to switch to one of the following APIs:
226233

@@ -229,7 +236,7 @@ In the React 18 Working Group we worked with library maintainers to create new A
229236

230237
React 18 also introduces new APIs for concurrent rendering such as `startTransition`, `useDeferredValue` and `useId`, which we share more about in the [release post](/blog/2022/03/29/react-v18).
231238

232-
## Updates to Strict Mode {/*updates-to-strict-mode*/}
239+
## Évolutions du mode strict {/*updates-to-strict-mode*/}
233240

234241
In the future, we'd like to add a feature that allows React to add and remove sections of the UI while preserving state. For example, when a user tabs away from a screen and back, React should be able to immediately show the previous screen. To do this, React would unmount and remount trees using the same component state as before.
235242

@@ -261,7 +268,7 @@ With Strict Mode in React 18, React will simulate unmounting and remounting the
261268

262269
For more information, see the Working Group posts for [Adding Reusable State to StrictMode](https://github.com/reactwg/react-18/discussions/19) and [How to support Reusable State in Effects](https://github.com/reactwg/react-18/discussions/18).
263270

264-
## Configuring Your Testing Environment {/*configuring-your-testing-environment*/}
271+
## Configurer votre environnement de test {/*configuring-your-testing-environment*/}
265272

266273
When you first update your tests to use `createRoot`, you may see this warning in your test console:
267274

@@ -286,29 +293,29 @@ Eventually, we expect testing libraries will configure this for you automaticall
286293

287294
[More background on the `act` testing API and related changes](https://github.com/reactwg/react-18/discussions/102) is available in the working group.
288295

289-
## Dropping Support for Internet Explorer {/*dropping-support-for-internet-explorer*/}
296+
## Arrêt de la prise en charge d'Internet Explorer {/*dropping-support-for-internet-explorer*/}
290297

291298
In this release, React is dropping support for Internet Explorer, which is [going out of support on June 15, 2022](https://blogs.windows.com/windowsexperience/2021/05/19/the-future-of-internet-explorer-on-windows-10-is-in-microsoft-edge). We’re making this change now because new features introduced in React 18 are built using modern browser features such as microtasks which cannot be adequately polyfilled in IE.
292299

293300
If you need to support Internet Explorer we recommend you stay with React 17.
294301

295-
## Deprecations {/*deprecations*/}
302+
## Dépréciations {/*deprecations*/}
296303

297304
* `react-dom`: `ReactDOM.render` has been deprecated. Using it will warn and run your app in React 17 mode.
298305
* `react-dom`: `ReactDOM.hydrate` has been deprecated. Using it will warn and run your app in React 17 mode.
299306
* `react-dom`: `ReactDOM.unmountComponentAtNode` has been deprecated.
300307
* `react-dom`: `ReactDOM.renderSubtreeIntoContainer` has been deprecated.
301308
* `react-dom/server`: `ReactDOMServer.renderToNodeStream` has been deprecated.
302309

303-
## Other Breaking Changes {/*other-breaking-changes*/}
310+
## Autres ruptures de compatibilité ascendante {/*other-breaking-changes*/}
304311

305312
* **Consistent useEffect timing**: React now always synchronously flushes effect functions if the update was triggered during a discrete user input event such as a click or a keydown event. Previously, the behavior wasn't always predictable or consistent.
306313
* **Stricter hydration errors**: Hydration mismatches due to missing or extra text content are now treated like errors instead of warnings. React will no longer attempt to "patch up" individual nodes by inserting or deleting a node on the client in an attempt to match the server markup, and will revert to client rendering up to the closest `<Suspense>` boundary in the tree. This ensures the hydrated tree is consistent and avoids potential privacy and security holes that can be caused by hydration mismatches.
307314
* **Suspense trees are always consistent:** If a component suspends before it's fully added to the tree, React will not add it to the tree in an incomplete state or fire its effects. Instead, React will throw away the new tree completely, wait for the asynchronous operation to finish, and then retry rendering again from scratch. React will render the retry attempt concurrently, and without blocking the browser.
308315
* **Layout Effects with Suspense**: When a tree re-suspends and reverts to a fallback, React will now clean up layout effects, and then re-create them when the content inside the boundary is shown again. This fixes an issue which prevented component libraries from correctly measuring layout when used with Suspense.
309316
* **New JS Environment Requirements**: React now depends on modern browsers features including `Promise`, `Symbol`, and `Object.assign`. If you support older browsers and devices such as Internet Explorer which do not provide modern browser features natively or have non-compliant implementations, consider including a global polyfill in your bundled application.
310317

311-
## Other Notable Changes {/*other-notable-changes*/}
318+
## Autres évolutions notables {/*other-notable-changes*/}
312319

313320
### React {/*react*/}
314321

@@ -325,4 +332,4 @@ If you need to support Internet Explorer we recommend you stay with React 17.
325332

326333
## Changelog {/*changelog*/}
327334

328-
You can view the [full changelog here](https://github.com/facebook/react/blob/main/CHANGELOG.md).
335+
Vous pouvez consulter le [changelog complet ici](https://github.com/facebook/react/blob/main/CHANGELOG.md).

src/content/blog/2022/03/29/react-v18.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Ceci dit, sur le plus long terme, nous pensons que le principal moyen d'ajouter
6666

6767
Ça prendra sans doute un peu de temps pour que les bibliothèques se mettent à jour afin de prendre en charge la concurrence. Nous avons fourni de nouvelles API pour faciliter cette évolution des bibliothèques. Dans l'intervalle, faites preuve de patience avec les mainteneurs tandis que nous travaillons tou·te·s à faire évoluer l'écosystème de React.
6868

69-
Pour en savoir plus, consultez notre précédent billet : [Comment migrer vers React 18](/blog/2022/03/08/react-18-upgrade-guide).
69+
Pour en savoir plus, consultez notre précédent billet : [Comment migrer sur React 18](/blog/2022/03/08/react-18-upgrade-guide).
7070

7171
## Suspense dans les frameworks de données {/*suspense-in-data-frameworks*/}
7272

0 commit comments

Comments
 (0)