ReactJS unmountComponentAtNode() Method Last Updated : 10 Aug, 2023 Comments Improve Suggest changes Like Article Like Report React.js library is all about splitting the app into several components. Each Component has its own lifecycle. React provides us with some in-built methods that we can override at particular stages in the life-cycle of the component. In class-based components, the unmountComponentAtNode() method Remove a mounted React component from the DOM. Creating React Application: Step 1: Create a React application using the following command.npx create-react-app foldernameStep 2: After creating your project folder i.e. foldername, move to it using the following command.cd foldernameProject Structure: It will look like the following. Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code. App.js import React from 'react' import ReactDOM from 'react-dom'; // Exporting your App Component export default function App() { // Function to unmount root component function unm() { ReactDOM.unmountComponentAtNode(document.getElementById("root")); } return ( <div> <h1>GeeksforGeeks</h1> <div>Hi Geek, this is the rendered content</div> <button onClick={unm}>Unmount</button> </div> ); } Step to Run Application: Run the application using the following command from the root directory of the project: npm startOutput: Now open your browser and go to http://localhost:3000/, you will see the following output: Reference: https://react.dev/reference/react-dom/unmountComponentAtNode Comment More infoAdvertise with us Next Article ReactJS unmountComponentAtNode() Method D dheerchanana2002 Follow Improve Article Tags : Web Technologies ReactJS ReactJS-Methods Similar Reads ReactJS shouldComponentUpdate() Method In React, lifecycle methods provide hooks into different phases of a component's lifecycle, enabling developers to control its behaviour at various stages. One such lifecycle method is shouldComponentUpdate().It plays an important role in optimizing component rendering and ensuring that unnecessary 5 min read ReactJS TestRenderer.unmount() Method React.js library is all about splitting the app into several components. Each Component has its own lifecycle. React provides us some in-built methods that we can override at particular stages in the life-cycle of the component. In this article, we will know how to use TestRenderer.unmount() method. 1 min read What is the use of shouldComponenUpdate() methods in ReactJS ? The `shouldComponentUpdate()` method in class-based components is invoked before each re-render, excluding the initial render, triggered by updated props or state. Its default value is true but can be customized using conditional JSX, mainly employed for optimizing React web apps by preventing unnec 4 min read React useSyncExternalStore Hook State management is a critical aspect of React applications, and often, developers need to synchronize their application state with an external data store. React's useSyncExternalStore hook provides a seamless solution to this challenge. In this article, we'll explore what the useSyncExternalStore h 4 min read ReactJS useTimeout Custom Hook We often run into timeouts when building applications in React. setTimeout() executes code after a specified period only once. Usually, we don't need to worry about clearing out our timeouts when using setTimeout. However, it can be challenging to use the setTimeout method in React because we might 5 min read Like