mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 04:12:34 +00:00
Add more codemods (#6921)
This commit is contained in:
@@ -405,7 +405,7 @@ root.render(<App />);
|
||||
|
||||
<Note>
|
||||
|
||||
Codemod `ReactDOM.render` to `ReactDOM.createRoot`:
|
||||
Codemod `ReactDOM.render` to `ReactDOMClient.createRoot`:
|
||||
|
||||
```bash
|
||||
npx codemod@latest react/19/replace-reactdom-render
|
||||
@@ -427,6 +427,15 @@ import {hydrateRoot} from 'react-dom/client';
|
||||
hydrateRoot(document.getElementById('root'), <App />);
|
||||
```
|
||||
|
||||
<Note>
|
||||
|
||||
Codemod `ReactDOM.hydrate` to `ReactDOMClient.hydrateRoot`:
|
||||
|
||||
```bash
|
||||
npx codemod@latest react/19/replace-reactdom-render
|
||||
```
|
||||
|
||||
</Note>
|
||||
|
||||
#### Removed: `unmountComponentAtNode` {/*removed-unmountcomponentatnode*/}
|
||||
|
||||
@@ -443,8 +452,18 @@ root.unmount();
|
||||
|
||||
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).
|
||||
|
||||
<Note>
|
||||
|
||||
Codemod `unmountComponentAtNode` to `root.unmount`:
|
||||
|
||||
```bash
|
||||
npx codemod@latest react/19/replace-reactdom-render
|
||||
```
|
||||
|
||||
</Note>
|
||||
|
||||
#### Removed: `ReactDOM.findDOMNode` {/*removed-reactdom-finddomnode*/}
|
||||
|
||||
`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).
|
||||
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user