ReactJS findDOMNode() Method Last Updated : 09 Oct, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report findDOMNode in React is used to directly access a component's underlying DOM node. It is mainly used in class components for DOM manipulation, animations, or integration with third-party libraries. It's considered unsafe in modern React development.Syntax:ReactDOM.findDOMNode(component)Parameters:component: The component can be either a React component instance or a DOM element. When passed, it retrieves the corresponding DOM node associated with the component.Return Value:The findDOMNode() method returns the DOM node associated with the specified React component or null if the component is not mounted.Steps to Create React AppStep 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: A React component that changes the style of a specified DOM element when a button is clicked using findDOMNode(). JavaScript // Filename - App.js import React from "react"; import ReactDOM from "react-dom"; // Defining our App Component const App = () => { // Function to get element from findDOMNode() function find() { const node = document.getElementById("node"); const a = ReactDOM.findDOMNode(node); console.log(a); if (a) { a.style.color = "green"; a.style.fontSize = "x-large"; } } // Returning our JSX code return ( <> <div> <h1>GeeksforGeeks</h1> <div id="node">DOM Node</div> <button onClick={find}>Click to find</button> </div> </> ); }; // Exporting your Default App Component export default App; 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://reactjs.org/docs/react-dom.html#finddomnode Comment More infoAdvertise with us Next Article ReactJS componentDidMount() Method D dheerchanana2002 Follow Improve Article Tags : Web Technologies ReactJS ReactJS-Basics ReactJS-Methods Similar Reads ReactJS isDOMComponent() 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 isDOMComponent() method. This 2 min read ReactJS isElement() 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 isElement() method. The isElem 2 min read ReactJS isElementOfType() 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 isElementOfType() method. The 2 min read ReactJS componentDidMount() Method In React, componentDidMount() is a lifecycle method in React that is called once a component has been rendered and placed in the DOM. This method is invoked only once during the lifecycle of a component, immediately after the first render, which is why it is useful for operations like fetching data, 7 min read ReactJS isCompositeComponent() 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 see how to use isCompositeComponent() method. 2 min read ReactJS componentDidCatch() Method The componentDidCatch() method is invoked if some error occurs during the rendering phase of any lifecycle methods or any children components. This method is used to implement the Error Boundaries for the React application. It is called during the commit phase, so unlike getDerivedStateFromError() w 2 min read Like