Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

findDOMNode warning in StrictMode, or findDOMNode missing in React 19

ErrorWarning: findDOMNode is deprecated in StrictMode

Short answer

findDOMNode was deprecated in React 16.6 and is removed in React 19. The fix is a ref: createRef in a class component, useRef in a function component, and forwardRef when you need a child's DOM node. A library that still calls it must be replaced or updated.

  • Applies to React 18, React 19
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find out whether your own code or a package calls it. The stack in the warning names the component.

    grep -rn "findDOMNode" src
    grep -rln "findDOMNode" node_modules --include=*.js | head
  2. 2Match what you see, then jump to its fix

    1. 1The warning names one of your own componentsA class component calls findDOMNode(this)Fix
    2. 2findDOMNode is imported from react-dom in a function componentA function component imports findDOMNodeFix
    3. 3findDOMNode(this.child) or a wrapper that reaches into a childYou need the DOM node of a child componentFix

What does the error look like?

  • Warning: findDOMNode is deprecated in StrictMode
  • findDOMNode was passed an instance of Transition which is inside StrictMode
  • The app breaks on findDOMNode after upgrading to React 19, where it was removed

Cause 1 of 3

A class component calls findDOMNode(this)

1Check

findDOMNode only accepts class component instances. Wrapping the render output in a new element changes what it returns, which is why it is fragile.

grep -rn "findDOMNode(this)" src

2Fix

Create a ref as a class field, attach it to the element and read current after mount.

class Form extends React.Component {
  inputRef = React.createRef();
  componentDidMount() { this.inputRef.current.focus(); }
  render() { return <input ref={this.inputRef} />; }
}

3Verify

Run the app in StrictMode; the warning disappears.

npm run dev

Confirmed by 18.react.dev

Did this fix it?

Cause 2 of 3

A function component imports findDOMNode

1Check

React 19 removed ReactDOM.findDOMNode. Its replacement is a DOM ref.

grep -rn "from 'react-dom'" src | grep findDOMNode

2Fix

Use useRef and read ref.current inside an effect.

function AutoselectingInput() {
  const ref = useRef(null);
  useEffect(() => {
    ref.current.select();
  }, []);
  return <input ref={ref} defaultValue="Hello" />;
}

3Verify

The input is selected on mount and no warning appears.

npm run dev

Confirmed by react.dev

Did this fix it?

Cause 3 of 3

You need the DOM node of a child component

1Check

Reaching into a child breaks abstraction. The child must hand its node to the parent.

grep -rn "findDOMNode(" src

2Fix

Create a ref in the parent and pass it down through a component wrapped in forwardRef. For measuring or scrolling a group of children, wrap them in a div with a ref, accepting that extra wrappers can affect styling.

const MyInput = forwardRef((props, ref) => <input {...props} ref={ref} />);

function Parent() {
  const ref = useRef(null);
  return <MyInput ref={ref} />;
}

3Verify

The parent can read ref.current after mount.

npm run dev

Confirmed by 18.react.dev

Did this fix it?

How do I stop it coming back?

  • Treat the StrictMode warning as a to do item; the API is gone in React 19.
  • Check dependencies against the React 19 upgrade guide before upgrading.
  • Use refs for DOM access in new code.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.