In React 18, `hydrate` was replaced by [`hydrateRoot`.](/apis/react-dom/client/hydrateRoot) Using `hydrate` in React 18 will warn that your app will behave as if it’s running React 17. Learn more [here.](https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#updates-to-client-rendering-apis)
</Pitfall>
This API will be removed in a future major version of React.
</Deprecated>
<Intro>
@ -163,12 +166,18 @@ Remember to be mindful of user experience on slow connections. The JavaScript co
In React 18, `hydrate` was replaced by [`hydrateRoot`.](/apis/react-dom/client/hydrateRoot) Using `hydrate` in React 18 will warn that your app will behave as if it’s running React 17. Learn more [here.](https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#updates-to-client-rendering-apis)
This API will be removed in a future major version of React.
</Deprecated>
Call `hydrate` in React 17 and below to “attach” React to existing HTML that was already rendered by React in a server environment.
In React 18, `render` was replaced by [`createRoot`.](/apis/react-dom/client/createRoot) Using `render` in React 18 will warn that your app will behave as if it’s running React 17. Learn more [here.](https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#updates-to-client-rendering-apis)
</Pitfall>
This API will be removed in a future major version of React.
</Deprecated>
<Intro>
@ -178,6 +179,14 @@ It is uncommon to call `render` multiple times. Usually, you'll [update state](/
In React 18, `render` was replaced by [`createRoot`.](/apis/react-dom/client/createRoot) Using `render` in React 18 will warn that your app will behave as if it’s running React 17. Learn more [here.](https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#updates-to-client-rendering-apis)
This API will be removed in a future major version of React.
</Deprecated>
Call `render` to display a React component inside a browser DOM element.
This section is incomplete, please see the old docs for [unmountComponentAtNode.](https://reactjs.org/docs/react-dom.html#unmountcomponentatnode)
In React 18, `unmountComponentAtNode` was replaced by [`root.unmount()`](/apis/react-dom/client/createRoot#root-unmount).
</Wip>
This API will be removed in a future major version of React.
</Deprecated>
<Intro>
Remove a mounted React component from the DOM and clean up its event handlers and state. If no component was mounted in the container, calling this function does nothing. Returns `true` if a component was unmounted and `false` if there was no component to unmount.
`unmountComponentAtNode` removes a mounted React component from the DOM.
```js
unmountComponentAtNode(container)
unmountComponentAtNode(domNode)
```
</Intro>
<InlineToc/>
---
## Usage {/*usage*/}
Call `unmountComponentAtNode` to remove a <CodeStepstep={1}>mounted React component</CodeStep> from a <CodeStepstep={2}>browser DOM node</CodeStep> and clean up its event handlers and state.
import {render, unmountComponentAtNode} from 'react-dom';
import App from './App.js';
const rootNode = document.getElementById('root');
render(<App/>, rootNode);
// ...
unmountComponentAtNode(rootNode);
````
### Removing a React app from a DOM element {/*removing-a-react-app-from-a-dom-element*/}
Occasionally, you may want to "sprinkle" React on an existing page, or a page that is not fully written in React. In those cases, you may need to "stop" the React app, by removing all of the UI, state, and listeners from the DOM node it was rendered to.
In this example, clicking "Render React App" will render a React app. Click "Unmount React App" to destroy it:
<Sandpack>
```html index.html
<!DOCTYPE html>
<html>
<head><title>My app</title></head>
<body>
<buttonid='render'>Render React App</button>
<buttonid='unmount'>Unmount React App</button>
<!-- This is the React App node -->
<divid='root'></div>
</body>
</html>
```
```js index.js active
import './styles.css';
import {render, unmountComponentAtNode} from 'react-dom';