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/blog/2024/04/25/react-19-upgrade-guide.md
+79-21
Original file line number
Diff line number
Diff line change
@@ -1,26 +1,18 @@
1
1
---
2
-
title: "React 19 Beta Upgrade Guide"
2
+
title: "React 19 RC Upgrade Guide"
3
3
author: Ricky Hanlon
4
4
date: 2024/04/25
5
-
description: The improvements added to React 19 require some breaking changes, but we've worked to make the upgrade as smooth as possible and we don't expect the changes to impact most apps. In this post, we will guide you through the steps for upgrading libraries to React 19 beta.
5
+
description: The improvements added to React 19 require some breaking changes, but we've worked to make the upgrade as smooth as possible and we don't expect the changes to impact most apps. In this post, we will guide you through the steps for upgrading apps and libraries to React 19.
6
6
---
7
7
8
8
April 25, 2024 by [Ricky Hanlon](https://twitter.com/rickhanlonii)
9
9
10
10
---
11
11
12
-
<Note>
13
-
14
-
This beta release is for libraries to prepare for React 19. App developers should upgrade to 18.3.0 and wait for React 19 stable as we work with libraries and make changes based on feedback.
15
-
16
-
</Note>
17
-
18
12
19
13
<Intro>
20
14
21
-
The improvements added to React 19 require some breaking changes, but we've worked to make the upgrade as smooth as possible and we don't expect the changes to impact most apps.
22
-
23
-
To help make the upgrade easier, today we are also publishing React 18.3.
15
+
The improvements added to React 19 RC require some breaking changes, but we've worked to make the upgrade as smooth as possible, and we don't expect the changes to impact most apps.
24
16
25
17
</Intro>
26
18
@@ -36,16 +28,17 @@ For a list of changes in 18.3 see the [Release Notes](https://github.com/faceboo
36
28
37
29
</Note>
38
30
39
-
In this post, we will guide you through the steps for upgrading libraries to React 19 beta:
31
+
In this post, we will guide you through the steps for upgrading to React 19:
40
32
41
33
-[Installing](#installing)
34
+
-[Codemods](#codemods)
42
35
-[Breaking changes](#breaking-changes)
43
36
-[New deprecations](#new-deprecations)
44
37
-[Notable changes](#notable-changes)
45
38
-[TypeScript changes](#typescript-changes)
46
39
-[Changelog](#changelog)
47
40
48
-
If you'd like to help us test React 19, follow the steps in this upgrade guide and [report any issues](https://github.com/facebook/react/issues/new?assignees=&labels=React+19&projects=&template=19.md&title=%5BReact+19%5D) you encounter. For a list of new features added to React 19 beta, see the [React 19 release post](/blog/2024/04/25/react-19).
41
+
If you'd like to help us test React 19, follow the steps in this upgrade guide and [report any issues](https://github.com/facebook/react/issues/new?assignees=&labels=React+19&projects=&template=19.md&title=%5BReact+19%5D) you encounter. For a list of new features added to React 19, see the [React 19 release post](/blog/2024/04/25/react-19).
49
42
50
43
---
51
44
## Installing {/*installing*/}
@@ -77,26 +70,57 @@ We expect most apps will not be affected since the transform is enabled in most
77
70
To install the latest version of React and React DOM:
78
71
79
72
```bash
80
-
npm install react@beta react-dom@beta
73
+
npm install react@rc react-dom@rc
81
74
```
82
75
83
-
If you're using TypeScript, you also need to update the types. Once React 19 is released as stable, you can install the types as usual from `@types/react` and `@types/react-dom`. During the beta period, the types are available in different packages which need to be enforced in your `package.json`:
76
+
If you're using TypeScript, you also need to update the types. Once React 19 is released as stable, you can install the types as usual from `@types/react` and `@types/react-dom`. Until the stable release, the types are available in different packages which need to be enforced in your `package.json`:
84
77
85
78
```json
86
79
{
87
80
"dependencies": {
88
-
"@types/react": "npm:types-react@beta",
89
-
"@types/react-dom": "npm:types-react-dom@beta"
81
+
"@types/react": "npm:types-react@rc",
82
+
"@types/react-dom": "npm:types-react-dom@rc"
90
83
},
91
84
"overrides": {
92
-
"@types/react": "npm:types-react@beta",
93
-
"@types/react-dom": "npm:types-react-dom@beta"
85
+
"@types/react": "npm:types-react@rc",
86
+
"@types/react-dom": "npm:types-react-dom@rc"
94
87
}
95
88
}
96
89
```
97
90
98
91
We're also including a codemod for the most common replacements. See [TypeScript changes](#typescript-changes) below.
99
92
93
+
## Codemods {/*codemods*/}
94
+
95
+
To help with the upgrade, we've worked with the team at [codemod.com](https://codemod.com) to publish codemods that will automatically update your code to many of the new APIs and patterns in React 19.
96
+
97
+
All codemods are available in the [`react-codemod` repo](https://github.com/reactjs/react-codemod) and the Codemod team have joined in helping maintain the codemods. To run these codemods, we recommend using the `codemod` command instead of the `react-codemod` because it runs faster, handles more complex code migrations, and provides better support for TypeScript.
98
+
99
+
100
+
<Note>
101
+
102
+
#### Run all React 19 codemods {/*run-all-react-19-codemods*/}
103
+
104
+
Run all codemods listed in this guide with the React 19 `codemod` recipe:
105
+
106
+
```bash
107
+
npx codemod@latest react/19/migration-recipe
108
+
```
109
+
110
+
This will run the following codemods from `react-codemod`:
#### Removed: `propTypes` and `defaultProps` for functions {/*removed-proptypes-and-defaultprops*/}
131
-
`PropTypes` were deprecated in [April 2017 (v15.5.0)](https://legacy.reactjs.org/blog/2017/04/07/react-v15.5.0.html#new-deprecation-warnings).
155
+
`PropTypes` were deprecated in [April 2017 (v15.5.0)](https://legacy.reactjs.org/blog/2017/04/07/react-v15.5.0.html#new-deprecation-warnings).
132
156
133
157
In React 19, we're removing the `propType` checks from the React package, and using them will be silently ignored. If you're using `propTypes`, we recommend migrating to TypeScript or another type-checking solution.
#### Removed: Legacy Context using `contextTypes` and `getChildContext` {/*removed-removing-legacy-context*/}
162
196
163
197
Legacy Context was deprecated in [October 2018 (v16.6.0)](https://legacy.reactjs.org/blog/2018/10/23/react-v-16-6.html).
@@ -253,7 +287,11 @@ class MyComponent extends React.Component {
253
287
254
288
<Note>
255
289
256
-
To help with the migration, we will be publishing a [react-codemod](https://github.com/reactjs/react-codemod/#string-refs) to automatically replace string refs with `ref` callbacks. Follow [this PR](https://github.com/reactjs/react-codemod/pull/309) for updates and to try it out.
290
+
Codemod string refs with `ref` callbacks:
291
+
292
+
```bash
293
+
npx codemod@latest react/19/replace-string-ref
294
+
```
257
295
258
296
</Note>
259
297
@@ -340,6 +378,16 @@ All other `test-utils` functions have been removed. These utilities were uncommo
340
378
341
379
See the [warning page](https://react.dev/warnings/react-dom-test-utils) for alternatives.
`ReactDOM.render` was deprecated in [March 2022 (v18.0.0)](https://react.dev/blog/2022/03/08/react-18-upgrade-guide). In React 19, we're removing `ReactDOM.render` and you'll need to migrate to using [`ReactDOM.createRoot`](https://react.dev/reference/react-dom/client/createRoot):
`ReactDOM.hydrate` was deprecated in [March 2022 (v18.0.0)](https://react.dev/blog/2022/03/08/react-18-upgrade-guide). In React 19, we're removing `ReactDOM.hydrate` you'll need to migrate to using [`ReactDOM.hydrateRoot`](https://react.dev/reference/react-dom/client/hydrateRoot),
Copy file name to clipboardExpand all lines: src/content/blog/2024/04/25/react-19.md
+5-12
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,21 @@
1
1
---
2
-
title: "React 19 Beta"
2
+
title: "React 19 RC"
3
3
author: The React Team
4
4
date: 2024/04/25
5
-
description: React 19 Beta is now available on npm! In this post, we'll give an overview of the new features in React 19, and how you can adopt them.
5
+
description: React 19 RC is now available on npm! In this post, we'll give an overview of the new features in React 19, and how you can adopt them.
6
6
---
7
7
8
8
April 25, 2024 by [The React Team](/community/team)
9
9
10
10
---
11
11
12
-
<Note>
13
-
14
-
This beta release is for libraries to prepare for React 19. App developers should upgrade to 18.3.0 and wait for React 19 stable as we work with libraries and make changes based on feedback.
15
-
16
-
</Note>
17
-
18
12
<Intro>
19
13
20
-
React 19 Beta is now available on npm!
14
+
React 19 RC is now available on npm!
21
15
22
16
</Intro>
23
17
24
-
In our [React 19 Beta Upgrade Guide](/blog/2024/04/25/react-19-upgrade-guide), we shared step-by-step instructions for upgrading your app to React 19 Beta. In this post, we'll give an overview of the new features in React 19, and how you can adopt them.
18
+
In our [React 19 RC Upgrade Guide](/blog/2024/04/25/react-19-upgrade-guide), we shared step-by-step instructions for upgrading your app to React 19. In this post, we'll give an overview of the new features in React 19, and how you can adopt them.
25
19
26
20
-[What's new in React 19](#whats-new-in-react-19)
27
21
-[Improvements in React 19](#improvements-in-react-19)
@@ -510,8 +504,7 @@ Due to the introduction of ref cleanup functions, returning anything else from a
510
504
511
505
The original code returned the instance of the `HTMLDivElement` and TypeScript wouldn't know if this was _supposed_ to be a cleanup function or if you didn't want to return a cleanup function.
512
506
513
-
You can codemod this pattern with [`no-implicit-ref-callback-return
You can codemod this pattern with [`no-implicit-ref-callback-return`](https://github.com/eps1lon/types-react-codemod/#no-implicit-ref-callback-return).
515
508
516
509
### `useDeferredValue` initial value {/*use-deferred-value-initial-value*/}
0 commit comments