ReactJS unmountComponentAtNode() Method Last Updated : 23 Jul, 2025 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://18.react.dev/reference/react-dom/unmountComponentAtNode Comment More infoAdvertise with us D dheerchanana2002 Follow Improve Article Tags : Web Technologies ReactJS ReactJS-Methods Explore React Tutorial 7 min read React FundamentalsReact Introduction 6 min read React Environment Setup 3 min read React JS ReactDOM 2 min read React JSX 5 min read ReactJS Rendering Elements 3 min read React Lists 4 min read React Forms 4 min read ReactJS Keys 4 min read Components in ReactReact Components 4 min read ReactJS Functional Components 4 min read React Class Components 3 min read ReactJS Pure Components 4 min read ReactJS Container and Presentational Pattern in Components 2 min read ReactJS PropTypes 5 min read React Lifecycle 7 min read React HooksReact Hooks 8 min read React useState Hook 5 min read ReactJS useEffect Hook 5 min read Routing in ReactReact Router 5 min read React JS Types of Routers 10 min read Advanced React ConceptsLazy Loading in React and How to Implement it ? 4 min read ReactJS Higher-Order Components 5 min read Code Splitting in React 4 min read React ProjectsCreate ToDo App using ReactJS 3 min read Create a Quiz App using ReactJS 4 min read Create a Coin Flipping App using ReactJS 3 min read How to create a Color-Box App using ReactJS? 4 min read Dice Rolling App using ReactJS 4 min read Guess the number with React 3 min read Like