diff --git a/code/lib/react-dom-shim/src/preset.ts b/code/lib/react-dom-shim/src/preset.ts index 846bbca678b0..cfd44f567649 100644 --- a/code/lib/react-dom-shim/src/preset.ts +++ b/code/lib/react-dom-shim/src/preset.ts @@ -3,9 +3,8 @@ import type { Options } from '@storybook/types'; import { version } from 'react-dom/package.json'; export const webpackFinal = async (config: any, options: Options) => { - const { legacyRootApi } = await options.presets.apply<{ legacyRootApi?: boolean }>( - 'frameworkOptions' - ); + const { legacyRootApi } = + (await options.presets.apply<{ legacyRootApi?: boolean } | null>('frameworkOptions')) || {}; const isReact18 = version.startsWith('18') || version.startsWith('0.0.0'); const useReact17 = legacyRootApi ?? !isReact18; @@ -24,9 +23,8 @@ export const webpackFinal = async (config: any, options: Options) => { }; export const viteFinal = async (config: any, options: Options) => { - const { legacyRootApi } = await options.presets.apply<{ legacyRootApi?: boolean }>( - 'frameworkOptions' - ); + const { legacyRootApi } = + (await options.presets.apply<{ legacyRootApi?: boolean } | null>('frameworkOptions')) || {}; const isReact18 = version.startsWith('18') || version.startsWith('0.0.0'); const useReact17 = legacyRootApi || !isReact18;