Skip to content

feat: Use the same React release channel as Next.js #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

elecdeer
Copy link

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
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