Skip to content

Commit b12743c

Browse files
authored
Add more codemods (#6921)
1 parent ad1a5c2 commit b12743c

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

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

+20-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ root.render(<App />);
405405

406406
<Note>
407407

408-
Codemod `ReactDOM.render` to `ReactDOM.createRoot`:
408+
Codemod `ReactDOM.render` to `ReactDOMClient.createRoot`:
409409

410410
```bash
411411
npx codemod@latest react/19/replace-reactdom-render
@@ -427,6 +427,15 @@ import {hydrateRoot} from 'react-dom/client';
427427
hydrateRoot(document.getElementById('root'), <App />);
428428
```
429429

430+
<Note>
431+
432+
Codemod `ReactDOM.hydrate` to `ReactDOMClient.hydrateRoot`:
433+
434+
```bash
435+
npx codemod@latest react/19/replace-reactdom-render
436+
```
437+
438+
</Note>
430439

431440
#### Removed: `unmountComponentAtNode` {/*removed-unmountcomponentatnode*/}
432441

@@ -443,8 +452,18 @@ root.unmount();
443452

444453
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).
445454

455+
<Note>
456+
457+
Codemod `unmountComponentAtNode` to `root.unmount`:
458+
459+
```bash
460+
npx codemod@latest react/19/replace-reactdom-render
461+
```
462+
463+
</Note>
446464

447465
#### Removed: `ReactDOM.findDOMNode` {/*removed-reactdom-finddomnode*/}
466+
448467
`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).
449468

450469
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):

0 commit comments

Comments
 (0)