Skip to content

Commit fe42437

Browse files
committed
More upgrade content
1 parent 1d76918 commit fe42437

File tree

2 files changed

+118
-50
lines changed

2 files changed

+118
-50
lines changed

src/components/MDX/ConsoleBlock.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ export function ConsoleBlock({level = 'error', children}: ConsoleBlockProps) {
4242
}
4343

4444
return (
45-
<div className="console-block mb-4 text-secondary" translate="no" dir="ltr">
45+
<div
46+
className="console-block mb-4 text-secondary bg-wash dark:bg-wash-dark rounded-lg"
47+
translate="no"
48+
dir="ltr">
4649
<div className="flex w-full rounded-t-lg bg-gray-200 dark:bg-gray-80">
4750
<div className="px-4 py-2 border-gray-300 dark:border-gray-90 border-r">
4851
<Box className="bg-gray-300 dark:bg-gray-70" width="15px" />
@@ -79,7 +82,10 @@ export function ConsoleBlock({level = 'error', children}: ConsoleBlockProps) {
7982

8083
export function ConsoleBlockMulti({children}: ConsoleBlockMultiProps) {
8184
return (
82-
<div className="console-block mb-4 text-secondary" translate="no" dir="ltr">
85+
<div
86+
className="console-block mb-4 text-secondary bg-wash dark:bg-wash-dark rounded-lg"
87+
translate="no"
88+
dir="ltr">
8389
<div className="flex w-full rounded-t-lg bg-gray-200 dark:bg-gray-80">
8490
<div className="px-4 py-2 border-gray-300 dark:border-gray-90 border-r">
8591
<Box className="bg-gray-300 dark:bg-gray-70" width="15px" />

src/content/blog/2024/04/01/react-19-upgrade-guide.md

Lines changed: 110 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,34 @@ April 1, 2024 by [Ricky Hanlon](https://twitter.com/rickhanlonii)
66

77
---
88

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+
919
<Note>
1020

11-
Stream [React Conf 2024]((https://conf.react.dev)) live May 15–16!
1221

13-
</Note>
1422

15-
<Intro>
23+
#### Upgrade to 18.3 first {/*upgrade-to-18-3-first*/}
1624

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.
1826

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.
2028

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.
2232

2333
- [Installing](#installing)
24-
- [Removing deprecated React APIs](#removing-deprecated-react-apis)
25-
- [Removing deprecated React DOM APIs](#removing-deprecated-react-dom-apis)
2634
- [Breaking Changes](#breaking-changes)
35+
- [Removed React APIs](#removed-react-apis)
36+
- [Removed React DOM APIs](#removed-react-dom-apis)
2737
- [New Deprecations](#new-deprecations)
2838
- [Other Breaking Changes](#other-breaking-changes)
2939
- [Other Notable changes](#other-notable-changes)
@@ -54,7 +64,7 @@ If you the new transform is not enabled, you will see this warning:
5464

5565
<ConsoleBlockMulti>
5666

57-
<ConsoleLogLine level="warning">
67+
<ConsoleLogLine level="error">
5868

5969
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
6070

@@ -67,9 +77,35 @@ We expect most apps will not be affected since the transform is enabled in most
6777

6878
</Note>
6979

70-
## Removing deprecated React APIs {/*removing-deprecated-react-apis*/}
80+
## Breaking Changes {/*breaking-changes*/}
81+
82+
### `element.ref` not supported {/*element-ref-not-supported*/}
83+
84+
TODO
7185

72-
### Removing `propTypes` and `defaultProps` {/*removing-proptypes-and-defaultprops*/}
86+
### Errors in render are not re-thrown {/*errors-in-render-are-not-re-thrown*/}
87+
88+
TODO
89+
TODO: need expect(act()).toThrow();
90+
91+
### Transitions in popstate are now synchronous {/*transitions-in-popstate-are-now-synchronous*/}
92+
93+
TODO
94+
95+
### StrictMode changes {/*strict-mode-improvements*/}
96+
97+
TODO
98+
99+
- https://github.com/facebook/react/pull/25583
100+
- https://github.com/facebook/react/pull/25049
101+
102+
### SECRET_INTERNALS have been renamed {/*secret-internals-have-been-renamed*/}
103+
104+
TODO
105+
106+
## Removed deprecated React APIs {/*removed-deprecated-react-apis*/}
107+
108+
### Removed: `propTypes` and `defaultProps` for functions {/*removed-proptypes-and-defaultprops*/}
73109
`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).
74110

75111
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.
@@ -100,7 +136,7 @@ function Heading({text = 'Hello, world!'}: Props) {
100136
}
101137
```
102138

103-
### Removing Legacy Context {/*removing-legacy-context*/}
139+
### Removed: Legacy Context using `contextTypes` and `getChildContext` {/*removed-removing-legacy-context*/}
104140

105141
Legacy Context was deprecated in [October 2018 (v16.6.0)](https://legacy.reactjs.org/blog/2018/10/23/react-v-16-6.html).
106142

@@ -160,7 +196,7 @@ class Child extends React.Component {
160196
}
161197
```
162198

163-
### Removing string refs {/*removing-string-refs*/}
199+
### Removed: string refs {/*removed-string-refs*/}
164200
String refs were deprecated in [March, 2018 (v16.3.0)](https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html).
165201

166202
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.
@@ -201,7 +237,7 @@ TODO: instructions.
201237

202238
</Note>
203239

204-
### Removing module pattern factories {/*removing-module-pattern-factories*/}
240+
### Removed: Module pattern factories {/*removed-module-pattern-factories*/}
205241
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).
206242

207243
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:
@@ -220,7 +256,7 @@ function FactoryComponent() {
220256
}
221257
```
222258

223-
### Removing `createFactory` {/*removing-createfactory*/}
259+
### Removed: `React.createFactory` {/*removed-createfactory*/}
224260
`createFactory` was deprecated in [February 2020 (v16.13.0)](https://legacy.reactjs.org/blog/2020/02/26/react-v16.13.0.html#deprecating-createfactory).
225261

226262
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:
@@ -237,7 +273,7 @@ const button = createFactory('button');
237273
const button = <button />;
238274
```
239275

240-
### Removing `react-test-renderer/shallow` {/*removing-react-test-renderer-shallow*/}
276+
### Removed: `react-test-renderer/shallow` {/*removed-react-test-renderer-shallow*/}
241277

242278
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:
243279

@@ -257,9 +293,9 @@ Shallow rendering depends on React internals and can block you from future upgra
257293

258294
</Note>
259295

260-
## Removing deprecated React DOM APIs {/*removing-deprecated-react-dom-apis*/}
296+
## Removed deprecated React DOM APIs {/*removed-deprecated-react-dom-apis*/}
261297

262-
### Removing `react-dom/test-utils` {/*removing-react-dom-test-utils*/}
298+
### Removed: `react-dom/test-utils` {/*removed-react-dom-test-utils*/}
263299

264300
We've moved `act` from `react-dom/test-utils` to the `react` package:
265301

@@ -284,20 +320,56 @@ All other `test-utils` functions have been removed. These utilities were uncommo
284320

285321
See the [warning page](https://react.dev/warnings/react-dom-test-utils) to for alternatives.
286322

287-
### Removing `ReactDOM.render` {/*removing-reactdom-render*/}
323+
### Removed: `ReactDOM.render` {/*removed-reactdom-render*/}
288324

289-
TODO
325+
`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):
290326

291-
### Removing `ReactDOM.hydrate` {/*removing-reactdom-hydrate*/}
327+
```js
328+
// Before
329+
import {render} from 'react-dom';
330+
render(<App />, document.getElementById('root'));
292331

293-
TODO
332+
// After
333+
import {createRoot} from 'react-dom/client';
334+
const root = createRoot(document.getElementById('root'));
335+
root.render(<App />);
336+
```
294337

295-
### Removing `unmountComponentAtNode` {/*removing-unmountcomponentatnode*/}
338+
### Removed: `ReactDOM.hydrate` {/*removed-reactdom-hydrate*/}
296339

297-
TODO
340+
`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),
341+
342+
```js
343+
// Before
344+
import {hydrate} from 'react-dom';
345+
hydrate(<App />, document.getElementById('root'));
346+
347+
// After
348+
import {hydrateRoot} from 'react-dom/client';
349+
hydrate(document.getElementById('root'), <App />);
350+
```
351+
352+
353+
### Removed: `unmountComponentAtNode` {/*removed-unmountcomponentatnode*/}
354+
355+
`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()`.
298356

299-
### Removing `ReactDOM.findDOMNode` {/*removing-reactdom-finddomnode*/}
300-
`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:
357+
358+
```js
359+
// Before
360+
unmountComponentAtNode(document.getElementById('root'));
361+
362+
// After
363+
root.unmount();
364+
```
365+
366+
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).
367+
368+
369+
### Removed: `ReactDOM.findDOMNode` {/*removed-reactdom-finddomnode*/}
370+
`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):
301373

302374
```js
303375
// Before
@@ -325,25 +397,6 @@ function AutoselectingInput() {
325397
}
326398
```
327399

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*/}
340-
341-
TODO
342-
343-
### StrictMode improvements {/*strict-mode-improvements*/}
344-
345-
TODO
346-
347400
## New Deprecations {/*new-deprecations*/}
348401

349402
### Deprecating `react-test-renderer` {/*deprecating-react-test-renderer*/}
@@ -355,21 +408,30 @@ The test renderer was created before there were more viable testing strategies a
355408
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.
356409

357410

358-
359411
## Other Breaking Changes {/*other-breaking-changes*/}
360412

361413
- UMD builds have been removed
362414
- 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
416+
- react: warnAboutSpreadingKeyToJSX https://github.com/facebook/react/pull/25697
417+
- react: unified sync lane https://github.com/facebook/react/pull/25700
418+
- react: element.ref not supported
364419
- react-dom: Remove `errorInfo.digest` with warning (TODO)
365420
- react-dom: Removed unstable_renderSubtreeIntoContainer (TODO)
366421
- react-dom: Warn and don’t set empty string attributes for src/href (TODO: land)
367-
- react-dom: Error and do not allow javascript URLs in src/href (TODO: land)
422+
- react-dom: Error and do not allow javascript URLs in src/href (TODO: land) https://github.com/facebook/react/pull/26507
423+
- react-dom: Restore old behavior for empty href props on anchor tags
424+
- react-is: Remove deprecated methods from react-is
368425

369426
## Other Notable changes {/*other-notable-changes*/}
370427

371428
#### React {/*other-notable-changes-react*/}
429+
- better infinite loop detection
430+
- unified sync lane
372431

373432
#### React DOM {/*other-notable-changes-react-dom*/}
374433
- Removed layout effect warning during SSR.
375434
- Removed workaround for IE style sorting hydration errors (TODO: land)
435+
436+
#### React ART {/*other-notable-changes-react-art*/}
437+
- React ART now runs in concurrent rendering

0 commit comments

Comments
 (0)