facebook/react · error · Error
Unable to find node on an unmounted component.
Error message
Unable to find node on an unmounted component.
What it means
findHostInstance (the engine behind ReactDOM.findDOMNode) resolves a component instance to its DOM node via the internal fiber link on the instance. getInstance returned undefined while the object still has a render method, meaning it is a class instance whose fiber link is gone — a component that has already unmounted. findDOMNode is also deprecated, so this pattern should disappear entirely.
Source
Thrown at packages/react-reconciler/src/ReactFiberReconciler.js:164
const fiber = getInstance(parentComponent);
const parentContext = findCurrentUnmaskedContext(fiber);
if (fiber.tag === ClassComponent) {
const Component = fiber.type;
if (isLegacyContextProvider(Component)) {
return processChildContext(fiber, Component, parentContext);
}
}
return parentContext;
}
function findHostInstance(component: Object): PublicInstance | null {
const fiber = getInstance(component);
if (fiber === undefined) {
if (typeof component.render === 'function') {
throw new Error('Unable to find node on an unmounted component.');
} else {
const keys = Object.keys(component).join(',');
throw new Error(
`Argument appears to not be a ReactComponent. Keys: ${keys}`,
);
}
}
const hostFiber = findCurrentHostFiber(fiber);
if (hostFiber === null) {
return null;
}
return getPublicInstance(hostFiber.stateNode);
}
function findHostInstanceWithWarning(
component: Object,
methodName: string,
): PublicInstance | null {View on GitHub (pinned to eafeac097b)
Solutions
- Replace findDOMNode with refs (createRef / callback refs) on the element you need — findDOMNode is deprecated and discouraged under StrictMode
- Clear timers, subscriptions, and pending callbacks in componentWillUnmount so nothing runs after unmount
- Null out stored refs when the component unmounts and check them before use
- If a deferred callback must run, bail out early when the component (or its ref) is gone
Example fix
// before
componentDidMount() {
this.timer = setTimeout(() => {
const node = findDOMNode(this.child); // child may have unmounted -> throws
node.focus();
}, 1000);
}
// after
constructor(props) {
super(props);
this.nodeRef = React.createRef();
}
componentDidMount() {
this.timer = setTimeout(() => {
if (this.nodeRef.current) this.nodeRef.current.focus();
}, 1000);
}
componentWillUnmount() {
clearTimeout(this.timer);
} Defensive patterns
Strategy: type-guard
Type guard
// Pragmatic mounted-instance guard (fiber link exists = still mounted)
function isMountedClassInstance(x: unknown): boolean {
return (
x != null &&
typeof x === 'object' &&
typeof (x as any).render === 'function' &&
(x as any)._reactInternals !== undefined
);
} Prevention
- Replace findDOMNode with createRef/callback refs — it is deprecated
- Clear timers, RAFs, subscriptions, and pending promises in componentWillUnmount
- Null out refs on unmount and check them before use in deferred callbacks
- Prefer rendering-safe data flow (state via props) over resolving DOM nodes from instances
When it happens
Trigger: ReactDOM.findDOMNode(instance) called after that component unmounted: timers (setTimeout/requestAnimationFrame) firing post-unmount, promise callbacks resolving late, event handlers or store subscribers holding stale child refs.
Common situations: Cleanup races in class components; findDOMNode(this.refs.child) after the child swapped out; instances captured in long-lived objects (stores, observers) and queried later.
Related errors
- Argument appears to not be a ReactComponent. Keys: ${keys}
- Unable to find node on an unmounted component.
- An unsupported type was passed to use(): ${String(usable)}
- Unknown Fiber. Needs to be a function component to inspect h
- Cannot ${action} through a Bridge that has been shut down.
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/9b37812fbcd7198c.
Report an issue: GitHub.