diff --git a/packages/storybook/src/generators/configuration/lib/ensure-dependencies.ts b/packages/storybook/src/generators/configuration/lib/ensure-dependencies.ts index 66c0dbbc33a1f6..27f5a515f2256e 100644 --- a/packages/storybook/src/generators/configuration/lib/ensure-dependencies.ts +++ b/packages/storybook/src/generators/configuration/lib/ensure-dependencies.ts @@ -44,19 +44,21 @@ export function ensureDependencies( packageJson.dependencies ??= {}; packageJson.devDependencies ??= {}; - // Needed for Storybook 7 - // https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#react-peer-dependencies-required - if ( - !packageJson.dependencies['react'] && - !packageJson.devDependencies['react'] - ) { - dependencies['react'] = reactVersion; - } - if ( - !packageJson.dependencies['react-dom'] && - !packageJson.devDependencies['react-dom'] - ) { - dependencies['react-dom'] = reactVersion; + if (!gte(storybook7VersionToInstall, '8.0.0')) { + // Needed for Storybook 7 + // https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#react-peer-dependencies-required + if ( + !packageJson.dependencies['react'] && + !packageJson.devDependencies['react'] + ) { + dependencies['react'] = reactVersion; + } + if ( + !packageJson.dependencies['react-dom'] && + !packageJson.devDependencies['react-dom'] + ) { + dependencies['react-dom'] = reactVersion; + } } if (options.uiFramework) {