{"record":{"id":"6da11e629e7ff6b6","repo":"facebook/react","slug":"509","errorCode":"509","errorMessage":"ReactDOM: Unsupported Legacy Mode API.","messagePattern":"ReactDOM: Unsupported Legacy Mode API\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-dom/src/client/ReactDOMRootFB.js","lineNumber":399,"sourceCode":"  }\n  if (__DEV__) {\n    return findHostInstanceWithWarning(componentOrElement, 'findDOMNode');\n  }\n  return findHostInstance(componentOrElement);\n}\n\nexport function render(\n  element: React$Element<any>,\n  container: Container,\n  callback: ?Function,\n): component(...props: any) | PublicInstance | null {\n  if (disableLegacyMode) {\n    if (__DEV__) {\n      console.error(\n        'ReactDOM.render was removed in React 19. Use createRoot instead.',\n      );\n    }\n    throw new Error('ReactDOM: Unsupported Legacy Mode API.');\n  }\n  if (__DEV__) {\n    console.error(\n      'ReactDOM.render has not been supported since React 18. Use createRoot ' +\n        'instead. Until you switch to the new API, your app will behave as ' +\n        \"if it's running React 17. Learn \" +\n        'more: https://react.dev/link/switch-to-createroot',\n    );\n  }\n\n  if (!isValidContainer(container)) {\n    throw new Error('Target container is not a DOM element.');\n  }\n\n  if (__DEV__) {\n    const isModernRoot =\n      isContainerMarkedAsRoot(container) &&\n      container._reactRootContainer === undefined;","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-dom/src/client/ReactDOMRootFB.js#L381-L417","documentation":"ReactDOM.render is the legacy root API. With the disableLegacyMode flag (React 19 builds) it logs a migration note in DEV and then throws 'ReactDOM: Unsupported Legacy Mode API.' (code 509), making removal a hard error. The replacement is createRoot(container).render(element); the old callback second argument becomes an effect. Note this throw fires before the container validity check, so a bad container never reaches the code-299 error in this build.","triggerScenarios":"Calling ReactDOM.render(<App />, container, callback?) (or ReactDOM.hydrate) on a build where disableLegacyMode is true — i.e. React 19 — including via old tutorials, legacy wrappers, or dependencies that still call it.","commonSituations":"Upgrading React 17/18 codebases to 19 without migrating entry points; libraries wrapping ReactDOM.render (legacy modal or widget managers); call sites missed by upgrade codemods.","solutions":["Replace ReactDOM.render(el, container, cb) with createRoot(container).render(<App />) and move the callback into a useEffect","Replace ReactDOM.hydrate with hydrateRoot(container, initialChildren)","Run the React 19 upgrade codemod and search the repo for ReactDOM.render leftovers","Update or replace dependencies that internally call ReactDOM.render"],"exampleFix":"// before\nimport ReactDOM from 'react-dom';\nReactDOM.render(<App />, document.getElementById('root'));\n\n// after\nimport {createRoot} from 'react-dom/client';\ncreateRoot(document.getElementById('root')).render(<App />);","handlingStrategy":"fallback","validationCode":"import * as ReactDOM from 'react-dom';\nimport {version} from 'react';\n\nconst isLegacyRemoved = Number(version.split('.')[0]) >= 19;\n\nfunction mountApp(element, container) {\n  if (isLegacyRemoved) {\n    // React 19+: modern API\n    import('react-dom/client').then(({createRoot}) => {\n      createRoot(container).render(element);\n    });\n  } else {\n    ReactDOM.render(element, container);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Grep for ReactDOM.render and ReactDOM.hydrate during React 19 upgrades and migrate all call sites","Replace the callback argument with a useEffect inside the root component","Add an ESLint rule or codemod run in CI to block reintroduction of legacy root APIs"],"tags":["react-dom","react-19","legacy-api","render","migration"],"backgroundTag":"removed-legacy-api","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}