Skip to content
Tutorials Center
My learning

Topics

React Reference ยท react-dom Client APIs

ReactDOM.findDOMNode (removed)

ReactDOM.findDOMNode was removed in React 19. Learn what it did, why it was dropped, and how to replace it with refs in function and class components.

findDOMNode(component) used to take a class component instance and return the DOM node that the component rendered. It let code reach into a child's DOM without the child cooperating. It was deprecated in StrictMode in React 16.3, and it is removed in React 19: ReactDOM.findDOMNode is now undefined, and calling it throws a TypeError.

If you see it in old code or in an old library, replace it with a ref. A ref is explicit: the component that owns the DOM node hands it out on purpose.

JSX
// React 18 and earlier (do not use)
import { findDOMNode } from 'react-dom';
const node = findDOMNode(this);

Try it

Check that it is gone
The replacement: a ref

Migration

Situation Replacement
A class component needs its own root node Create the ref with createRef() and put ref={this.nodeRef} on the element it renders
A function component needs its own node useRef and ref={...} on the element
A parent needs a child's node The child accepts a ref prop (React 19, plain prop for function components) and attaches it to its element; before 19, use forwardRef
A child is a third-party component that renders one element Wrap it in a <div ref={...}>, or ask the library to accept a ref
You need to measure or focus Keep the ref in the component that does the measuring, and call node.focus() or getBoundingClientRect() in an effect
Libraries such as animation helpers that needed the node Update them; modern versions accept refs

Usage notes

  • It broke abstraction. A parent could grab any child's DOM, so a child could not change its output (add a wrapper, return a fragment, return null) without breaking the parent. findDOMNode also only returned the first node of a fragment.
  • It did not work with function components at all, so it never fit modern React.
  • Code using ReactDOM.findDOMNode through a package (older UI libraries, drag-and-drop tools, transition groups) needs an upgrade. If a package cannot be upgraded, pin it behind React 18 or replace it.
  • To know where a node is relative to the page, use getBoundingClientRect() on the ref, not a lookup by component.
  • react-transition-group and similar libraries expose a nodeRef prop for the same reason; pass a ref and avoid the old lookup path.