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
@@ -6,24 +6,34 @@ April 1, 2024 by [Ricky Hanlon](https://twitter.com/rickhanlonii)
6
6
7
7
---
8
8
9
+
<Intro>
10
+
11
+
12
+
As we shared in the [release post](/blog/2024/04/01/react-19), 19 adds new features like Actions, optimistic updates, and React Server Components. It also includes long-requested improvements like using refs without `forwardRef`, using `<Context>` as a provider, better error handling, and faster JSX.
13
+
14
+
The improvements added to React 19 require some breaking changes, but we've worked to make the upgrade as smooth as possible. We're also removing many long time deprecated APIs to make React simpler and easier to understand.
15
+
16
+
</Intro>
17
+
18
+
9
19
<Note>
10
20
11
-
Stream [React Conf 2024]((https://conf.react.dev)) live May 15–16!
12
21
13
-
</Note>
14
22
15
-
<Intro>
23
+
#### Upgrade to 18.3 first {/*upgrade-to-18-3-first*/}
16
24
17
-
Today we're releasing a beta version of React 19, the next major version of React. In this post, we will guide you through the steps for upgrading.
25
+
To help make the upgrade to React 19 easier, we've published a `[email protected]` release that only includes warnings for deprecated APIs and other changes that will be removed in React 19.
18
26
19
-
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/choose) you encounter.
27
+
We recommend upgrading to React 18.3 first to help identify any issues before upgrading to React 19.
20
28
21
-
</Intro>
29
+
</Note>
30
+
31
+
In this post, we will guide you through the steps for upgrading. 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/choose) you encounter.
@@ -54,7 +64,7 @@ If you the new transform is not enabled, you will see this warning:
54
64
55
65
<ConsoleBlockMulti>
56
66
57
-
<ConsoleLogLinelevel="warning">
67
+
<ConsoleLogLinelevel="error">
58
68
59
69
Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform
60
70
@@ -67,9 +77,35 @@ We expect most apps will not be affected since the transform is enabled in most
### Removed: `propTypes` and `defaultProps` for functions {/*removed-proptypes-and-defaultprops*/}
73
109
`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).
74
110
75
111
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.
String refs were deprecated in [March, 2018 (v16.3.0)](https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html).
165
201
166
202
Class components supported string refs before being replaced by ref callbacks due to [multiple downsides](https://github.com/facebook/react/issues/1373). In React 19, we're removing string refs to make React simpler and easier to understand.
Module pattern factories were deprecated in [August 2019 (v16.9.0)](https://legacy.reactjs.org/blog/2019/08/08/react-v16.9.0.html#deprecating-module-pattern-factories).
206
242
207
243
This pattern was rarely used and supporting it causes React to be slightly larger and slower than necessary. In React 19, we're removing support for module pattern factories, and you'll need to migrate to regular functions:
`createFactory` was deprecated in [February 2020 (v16.13.0)](https://legacy.reactjs.org/blog/2020/02/26/react-v16.13.0.html#deprecating-createfactory).
225
261
226
262
Using `createFactory` was common before broad support for JSX, but it's rarely used today and can be replaced with JSX. In React 19, we're removing `createFactory` and you'll need to migrate to JSX:
In React 18, we updated `react-test-renderer/shallow` to reexport [react-shallow-renderer](https://github.com/enzymejs/react-shallow-renderer). In React 19, we're removing `react-test-render/shallow` to prefer installing the package directly:
243
279
@@ -257,9 +293,9 @@ Shallow rendering depends on React internals and can block you from future upgra
257
293
258
294
</Note>
259
295
260
-
## Removing deprecated React DOM APIs {/*removing-deprecated-react-dom-apis*/}
296
+
## Removed deprecated React DOM APIs {/*removed-deprecated-react-dom-apis*/}
`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),
`ReactDOM.unmountComponentAtNode` was deprecated in [March 2022 (v18.0.0)](https://react.dev/blog/2022/03/08/react-18-upgrade-guide). In React 19, you'll need to migrate to using `root.unmount()`.
`ReactDOM.findDOMNode` was [deprecated in October 2018 (v16.6.0)](https://legacy.reactjs.org/blog/2018/10/23/react-v-16-6.html#deprecations-in-strictmode) because it was a legacy escape hatch that was slow to execute, fragile to refactoring, only returned the first child, and broke abstraction levels (see more [here](https://legacy.reactjs.org/docs/strict-mode.html#warning-about-deprecated-finddomnode-usage)). In React 19, we're removing `ReactDOM.findDOMNode` and you'll need to migrate to using refs:
For more see `root.unmount()` for [`createRoot`](https://react.dev/reference/react-dom/client/createRoot#root-unmount) and [`hydrateRoot`](https://react.dev/reference/react-dom/client/hydrateRoot#root-unmount).
`ReactDOM.findDOMNode` was [deprecated in October 2018 (v16.6.0)](https://legacy.reactjs.org/blog/2018/10/23/react-v-16-6.html#deprecations-in-strictmode).
371
+
372
+
We're removing `findDOMNode` because it was a legacy escape hatch that was slow to execute, fragile to refactoring, only returned the first child, and broke abstraction levels (see more [here](https://legacy.reactjs.org/docs/strict-mode.html#warning-about-deprecated-finddomnode-usage)). You can replace `ReactDOM.findDOMNode` with [DOM refs](/learn/manipulating-the-dom-with-refs):
301
373
302
374
```js
303
375
// Before
@@ -325,25 +397,6 @@ function AutoselectingInput() {
325
397
}
326
398
```
327
399
328
-
## Breaking Changes {/*breaking-changes*/}
329
-
330
-
### SECRET_INTERNALS have been renamed {/*secret-internals-have-been-renamed*/}
331
-
332
-
TODO
333
-
334
-
### Do not re-throw errors {/*do-not-rethrow-errors*/}
335
-
336
-
TODO
337
-
TODO: need expect(act()).toThrow();
338
-
339
-
### Transitions in popstate are now synchronous. {/*transitions-in-popstate-are-now-synchronous*/}
@@ -355,21 +408,30 @@ The test renderer was created before there were more viable testing strategies a
355
408
In React 19, `react-test-renderer` log a deprecation warning, and has switched to concurrent rendering by default. We recommend migrating your tests to [@testing-library/react](https://testing-library.com/docs/react-testing-library/intro/) or [@testing-library/react-native](https://callstack.github.io/react-native-testing-library/docs/getting-started) for a modern and well supported testing experience.
356
409
357
410
358
-
359
411
## Other Breaking Changes {/*other-breaking-changes*/}
360
412
361
413
- UMD builds have been removed
362
414
- react: Warn when using defaultProps in functions, memo, lazy, and forwardRef (TODO)
363
-
- react: Warn when spreading “key” as part of props in DEV (TODO)
415
+
- react: Don't prerender siblings of suspended component https://github.com/facebook/react/pull/26380
0 commit comments