{"record":{"id":"22491d510d2440f2","repo":"withastro/astro","slug":"unsupported-react-version-majorversion","errorCode":null,"errorMessage":"Unsupported React version: ${majorVersion}.","messagePattern":"Unsupported React version: (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/integrations/react/src/container-renderer.ts","lineNumber":20,"sourceCode":"import {\n\tgetReactMajorVersion,\n\tisSupportedReactVersion,\n\ttype ReactVersionConfig,\n\tversionsConfig,\n} from './version.js';\n\nexport function getRenderer(reactConfig: ReactVersionConfig): AstroRenderer {\n\treturn {\n\t\tname: '@astrojs/react',\n\t\tclientEntrypoint: reactConfig.client,\n\t\tserverEntrypoint: reactConfig.server,\n\t};\n}\n\nexport function getContainerRenderer(): AstroRenderer {\n\tconst majorVersion = getReactMajorVersion();\n\tif (!isSupportedReactVersion(majorVersion)) {\n\t\tthrow new Error(`Unsupported React version: ${majorVersion}.`);\n\t}\n\treturn getRenderer(versionsConfig[majorVersion]);\n}\n","sourceCodeStart":2,"sourceCodeEnd":24,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/integrations/react/src/container-renderer.ts#L2-L24","documentation":"getContainerRenderer() (used with Astro's Container API to render components in tests/SDKs) resolves the installed react-dom version and looks it up in versionsConfig, which contains entries for React 17, 18, and 19 only. Any other major (older, canary, or unresolvable yielding NaN) throws before a renderer can be constructed.","triggerScenarios":"Running container-based tests with react-dom 16 or an experimental/canary build; react-dom not installed so getReactMajorVersion returns NaN; a monorepo where the test resolves a different react-dom than the app.","commonSituations":"Trying React canary/next-major features before @astrojs/react supports them; installing react but not react-dom; hoisting/resolution issues in workspaces picking an old react-dom.","solutions":["Pin react and react-dom to a supported major, e.g. pnpm add react@^19 react-dom@^19","Make sure react-dom is actually installed; the version is read from it, not react","Update @astrojs/react to the latest release to pick up support for newer majors"],"exampleFix":"# before\nreact@canary react-dom@canary\n# after\nreact@^19 react-dom@^19","handlingStrategy":"type-guard","validationCode":"import { version } from 'react-dom';\nconst SUPPORTED = new Set([17, 18, 19]);\nconst major = Number(/\\d+\\./.exec(version)?.[0].replace('.', ''));\nif (!SUPPORTED.has(major)) throw new Error(`react-dom ${version} is unsupported; pin to 17/18/19`);","typeGuard":"const SUPPORTED_REACT_MAJORS = new Set([17, 18, 19]);\nfunction isSupportedReactMajor(major: number): major is 17 | 18 | 19 {\n  return SUPPORTED_REACT_MAJORS.has(major);\n}","tryCatchPattern":null,"preventionTips":["Pin react and react-dom to the same supported major in every workspace","Assert the version in test setup before calling getContainerRenderer()","Treat NaN majors as a missing react-dom dependency and fail the run early"],"tags":["react","version","container","peer-dependency"],"backgroundTag":"unsupported-library-version","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}