Skip to content

Commit

Permalink
Don't assume frameworkOptions will be an object
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeasday committed Mar 16, 2023
1 parent 8d09434 commit bc77248
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions code/lib/react-dom-shim/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }>('frameworkOptions')) || {};

const isReact18 = version.startsWith('18') || version.startsWith('0.0.0');
const useReact17 = legacyRootApi ?? !isReact18;
Expand All @@ -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 }>('frameworkOptions')) || {};

const isReact18 = version.startsWith('18') || version.startsWith('0.0.0');
const useReact17 = legacyRootApi || !isReact18;
Expand Down

0 comments on commit bc77248

Please sign in to comment.