diff --git a/code/lib/react-dom-shim/src/preset.ts b/code/lib/react-dom-shim/src/preset.ts index e863a53262b6..fbcb353c3827 100644 --- a/code/lib/react-dom-shim/src/preset.ts +++ b/code/lib/react-dom-shim/src/preset.ts @@ -6,7 +6,7 @@ import { readFile } from 'fs/promises'; * Get react-dom version from the resolvedReact preset, which points to either * a root react-dom dependency or the react-dom dependency shipped with addon-docs */ -const getIsReactVersion18 = async (options: Options) => { +const getIsReactVersion18or19 = async (options: Options) => { const { legacyRootApi } = (await options.presets.apply<{ legacyRootApi?: boolean } | null>('frameworkOptions')) || {}; @@ -24,11 +24,11 @@ const getIsReactVersion18 = async (options: Options) => { } const { version } = JSON.parse(await readFile(join(reactDom, 'package.json'), 'utf-8')); - return version.startsWith('18') || version.startsWith('0.0.0'); + return version.startsWith('18') || version.startsWith('19') || version.startsWith('0.0.0'); }; export const webpackFinal = async (config: any, options: Options) => { - const isReactVersion18 = await getIsReactVersion18(options); + const isReactVersion18 = await getIsReactVersion18or19(options); if (isReactVersion18) { return config; } @@ -46,7 +46,7 @@ export const webpackFinal = async (config: any, options: Options) => { }; export const viteFinal = async (config: any, options: Options) => { - const isReactVersion18 = await getIsReactVersion18(options); + const isReactVersion18 = await getIsReactVersion18or19(options); if (isReactVersion18) { return config; }