Skip to content

Conversation

@elecdeer
Copy link
Contributor

closes #52

The plugin was hardcoded to use Next.js's stable React compiled modules, but Next.js may use experimental React features depending on its configuration. This mismatch could cause issues when Next.js applications use experimental React features that require the experimental React channel.

Changes

  • Import needsExperimentalReact from Next.js to detect required React channel
  • Add bundledReactChannel variable that resolves to -experimental or empty string
  • Update all React module aliases to use the dynamic channel

@elecdeer
Copy link
Contributor Author

There is also a react: next/dist/compiled/react alias in src/mocks/storybook.global.ts, but I couldn't quite understand the situation where this module gets loaded.
I need to switch the react version here as well to match next.config.ts?

moduleAlias.addAliases({
react: "next/dist/compiled/react",
"react-dom/server": "next/dist/compiled/react-dom/server.js",
"react-dom/test-utils": require.resolve(
"next/dist/compiled/react-dom/cjs/react-dom-test-utils.production.js",
),
"react-dom": "next/dist/compiled/react-dom",
...getNextMocksAlias("node"),
...getNextImageAlias("node"),
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] unstable_ViewTransition is undefined in Storybook when experimental.viewTransition is enabled in Next.js

1 participant