{"record":{"id":"cc37b413ac092f4d","repo":"facebook/react","slug":"could-not-find-element-with-id-id","errorCode":null,"errorMessage":"Could not find element with id \"${id}\"","messagePattern":"Could not find element with id \"(.+?)\"","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/react-devtools-shared/src/backend/legacy/renderer.js","lineNumber":702,"sourceCode":"      style,\n    };\n  }\n\n  function updateSelectedElement(id: number): void {\n    const internalInstance = idToInternalInstanceMap.get(id);\n    if (internalInstance == null) {\n      console.warn(`Could not find instance with id \"${id}\"`);\n      return;\n    }\n\n    switch (getElementType(internalInstance)) {\n      case ElementTypeClass:\n        global.$r = internalInstance._instance;\n        break;\n      case ElementTypeFunction:\n        const element = internalInstance._currentElement;\n        if (element == null) {\n          console.warn(`Could not find element with id \"${id}\"`);\n          return;\n        }\n\n        global.$r = {\n          props: element.props,\n          type: element.type,\n        };\n        break;\n      default:\n        global.$r = null;\n        break;\n    }\n  }\n\n  function storeAsGlobal(\n    id: number,\n    path: Array<string | number>,\n    count: number,","sourceCodeStart":684,"sourceCodeEnd":720,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-devtools-shared/src/backend/legacy/renderer.js#L684-L720","documentation":"In updateSelectedElement() of the legacy DevTools backend, the internal instance was found in idToInternalInstanceMap, but its _currentElement is null. In the legacy reconciler _currentElement is cleared while the instance is between elements (mid re-render or during unmount), so DevTools cannot read props/type to build $r and warns instead. It means the instance exists but is not currently holding an element.","triggerScenarios":"Selecting a function component instance that is mid-update or being unmounted when DevTools evaluates updateSelectedElement; calling 'store as global variable' during a re-render triggered by setState in render or a sync layout effect.","commonSituations":"Fast-updating legacy (React < 16) trees where the selection lands during a commit; HMR swapping elements; components that unmount right after being clicked in the tree.","solutions":["Retry the selection after the current update finishes (re-click the element in the Components tree).","Disable the update source (pause the network/timer, use 'pause on exceptions') while inspecting.","Move the app to a modern React version so DevTools uses the Fiber backend, which reads props/type from the current Fiber instead."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Retry the selection after the in-flight commit finishes.","Inspect components that are not mid-update (avoid selecting during animations/polling).","Check that global.$r was actually set before using it in the console."],"tags":["react-devtools","legacy-renderer","element-selection","dev-only"],"backgroundTag":"stale-element-reference","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}