Skip to main content

findDOMNode

findDOMNode is deprecated and will be removed in a future version of React. Use refs instead.
Returns the browser DOM node corresponding to a React component instance.

Reference

findDOMNode(componentInstance)

Call findDOMNode to find the browser DOM node for a given React component instance.
/src/client/ReactDOMClient.js:43-47

Parameters

React.Component
required
An instance of a React component (typically this from a class component).

Returns

Element | Text | null
The browser DOM node corresponding to the component. Returns null if the component rendered null or false.

Why Is It Deprecated?

findDOMNode has several problems:
  1. Breaks abstraction - Reaches into component internals
  2. Only works with class components - Not compatible with function components
  3. Returns first child only - Confusing with fragments
  4. Prevents optimizations - React can’t optimize as much
  5. Breaks with Strict Mode - Causes issues in concurrent rendering

Migration Timeline

  • React 16.3: findDOMNode deprecated
  • React 17: Warning in Strict Mode
  • React 18: Stronger warnings
  • Future: Will be removed entirely

Migration Guide

Pattern 1: Forwarding Refs

Before (with findDOMNode):
After (with forwardRef):

Pattern 2: Direct Refs

Before (with findDOMNode):
After (with ref):

Pattern 3: Measuring Elements

Before (with findDOMNode):
After (with ref and ResizeObserver):

Pattern 4: Event Listeners

Before (with findDOMNode):
After (with ref):

Pattern 5: Third-Party Library Integration

Before (with findDOMNode):
After (with ref):

Common Scenarios

Focus Management

Scrolling to Element

Animation

TypeScript

Testing

When You Might Still See It

You might encounter findDOMNode in:
  1. Legacy codebases - Old React code not yet migrated
  2. Third-party libraries - Older libraries still using it
  3. React Native - Different implementation, not deprecated there

Best Practices

  1. Use refs instead - Modern, performant, and future-proof
  2. Forward refs when needed - For component composition
  3. Use useImperativeHandle - For exposing imperative methods
  4. Avoid DOM manipulation - Let React manage the DOM
  5. Migrate legacy code - Update findDOMNode usage proactively