facebook/react · warning
Could not find instance with id "${id}"
Error message
Could not find instance with id "${id}" What it means
updateSelectedElement() in the legacy DevTools backend (for pre-Fiber React, packages/react-devtools-shared/src/backend/legacy/renderer.js) assigns the currently selected element to console global $r. It first resolves the selected id via idToInternalInstanceMap; if the map has no entry, the element is gone from the renderer's view of the tree, so DevTools logs this warning and leaves $r untouched. This is a stale-id condition: the id was valid when selected but the instance was unmounted (or the renderer re-registered) before the lookup.
Source
Thrown at packages/react-devtools-shared/src/backend/legacy/renderer.js:691
if (internalInstance != null) {
instance = internalInstance._instance || null;
const element = internalInstance._currentElement;
if (element != null && element.props != null) {
style = element.props.style || null;
}
}
return {
instance,
style,
};
}
function updateSelectedElement(id: number): void {
const internalInstance = idToInternalInstanceMap.get(id);
if (internalInstance == null) {
console.warn(`Could not find instance with id "${id}"`);
return;
}
switch (getElementType(internalInstance)) {
case ElementTypeClass:
global.$r = internalInstance._instance;
break;
case ElementTypeFunction:
const element = internalInstance._currentElement;
if (element == null) {
console.warn(`Could not find element with id "${id}"`);
return;
}
global.$r = {
props: element.props,
type: element.type,
};View on GitHub (pinned to eafeac097b)
Solutions
- Re-select the element in the Components tree so the id-to-instance map is fresh, then retry the inspection.
- Freeze the UI (breakpoint, 'Emulate a focused page', or pause on unmount) so the element cannot disappear before you inspect it.
- Upgrade the app to React 16+ so DevTools uses the Fiber backend with a more robust id map.
Defensive patterns
Strategy: validation
Validate before calling
// Backend-internal; the equivalent guard if you drive a DevTools agent:
const renderer = agent.rendererInterfaces[rendererID];
if (renderer != null && renderer.hasElementWithId(id)) {
// safe to inspect/select
} Prevention
- Re-select the element right before using $r; do not hold $r across renders.
- Pause app updates (breakpoints, 'Emulate a focused page') while inspecting volatile components.
- Prefer Fiber-era React so DevTools uses the non-legacy backend.
When it happens
Trigger: Selecting an element in the Components tree and the component unmounting before DevTools runs updateSelectedElement (e.g. 'store as global variable' or re-selecting after an update); a hot reload replacing the root; calling inspect-at-point on a node removed by a timer or websocket update.
Common situations: Inspecting apps on React < 16 with the DevTools legacy backend while the UI keeps updating; holding an old selection across HMR; debugging components that unmount immediately after render.
Related errors
- Could not find element with id "${id}"
- Cannot not suspend ID '${suspendedSet[i]}'.
- Invalid renderer id "${rendererID}" for element "${id}"
- Invalid renderer id "${match.rendererID}" for element "${mat
- Profiling data cannot be updated while profiling is in progr
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/89b23ca0c749d2e4.
Report an issue: GitHub.