Skip to content

Warning: ReactDOM.findDOMNode is deprecated and will be removed

Error message

                ReactDOM.findDOMNode is deprecated and will be removed in a future version of React.
              

Quick summary

You called `ReactDOM.findDOMNode()` which is deprecated. Use refs attached to DOM elements instead.

Why this happens

  • Used ReactDOM.findDOMNode(this) in a class component

  • Copied from legacy React code

Minimal example

✗ Broken code
const node = ReactDOM.findDOMNode(this); // Deprecated!
✓ Fixed code
const myRef = useRef(null);
// Attach: <div ref={myRef} />
// Access: myRef.current

Refs are the modern, supported way to access DOM nodes. findDOMNode is removed in React 19.

How to diagnose

  • Search for findDOMNode in the codebase

  • Identify what DOM node it was trying to access

How to fix

  • Use a ref: this.myRef = React.createRef() and ref={this.myRef}

  • For function components: const myRef = useRef(null)

  • Access the node via myRef.current

How to prevent

  • Never use findDOMNode — always use refs

  • Use callback refs or useRef for DOM access

Related Resources

Related Glossary

Related Lessons

  • useRef

    Learn modern DOM access with refs.

← Back to language