Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React: Support v19 in react-dom-shim #26898

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions code/lib/react-dom-shim/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')) || {};

Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
Loading