Skip to content

Commit

Permalink
Merge pull request #26898 from Tobbe/tobbe-react-19
Browse files Browse the repository at this point in the history
React: Support v19 in `react-dom-shim`
(cherry picked from commit 34f0c20)
  • Loading branch information
JReinhold authored and storybook-bot committed May 4, 2024
1 parent ffc9f16 commit 2607b17
Showing 1 changed file with 4 additions and 4 deletions.
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

0 comments on commit 2607b17

Please sign in to comment.