storybook: Upgrading to React 17 on app level breaks UI
Here’s the repro: https://github.com/Hypnosphi/test-storybook-react-17
Error I get is:
react.development.js:1431 Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.
at resolveDispatcher (react.development.js:1431)
at Object.useContext (react.development.js:1439)
at useTheme (emotion-theming.browser.esm.js:112)
at useMenu (vendors~main.619dfba2fee0a3e45bd3.bundle.js:25841)
at Object.mapper [as current] (vendors~main.619dfba2fee0a3e45bd3.bundle.js:26274)
at ManagerConsumer (vendors~main.619dfba2fee0a3e45bd3.bundle.js:1484)
at renderWithHooks (vendors~main.619dfba2fee0a3e45bd3.bundle.js:42664)
at mountIndeterminateComponent (vendors~main.619dfba2fee0a3e45bd3.bundle.js:45343)
at beginWork (vendors~main.619dfba2fee0a3e45bd3.bundle.js:46457)
at HTMLUnknownElement.callCallback (vendors~main.619dfba2fee0a3e45bd3.bundle.js:28049)
Brief debugging showed that useTheme imports React from DLL while the rest of manager UI imports it from node_modules/@storybook/ui/node_modules/react
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 14
- Comments: 41 (24 by maintainers)
Commits related to this issue
- Temporarily add "--no-dll" to storybook commands to fix React@17 compat. See https://github.com/storybookjs/storybook/issues/12408 — committed to JetBrains/ring-ui by andrey-skl 4 years ago
- chore: add --no-dll to start-storybook script to fix react compatibility issue https://github.com/storybookjs/storybook/issues/12408 — committed to liamrdawson/photography-v2.0 by liamrdawson 4 years ago
- Upgrading everywhere to React 17 See https://github.com/storybookjs/storybook/issues/12408#issuecomment-716639680 for the temporary fix for React Storybook that kept pulling in React 16. — committed to Bullfrog-Labs/bullfrog by nybbles 4 years ago
- Nybbles/bul 43 get auth working (#27) * Adding Firebase Emulator logs to .gitignore * Integrating in LoginView and logging-in behavior * Upgrading everywhere to React 17 See https://github.c... — committed to Bullfrog-Labs/bullfrog by nybbles 4 years ago
Fixed in #12972 / 6.1-beta. Closing.
Any plans to also increase the react-dom range to support 17?
Edit, looks like there are issues with npm 7 + storybook as well.
--no-dllworks with React 17 as well.“yarn storybook --no-dll” works for me
NOTE: this is hopefully fixed in 6.1 ☝️ . We need to get it back into the stable release, but are having problems with repros in CI. In the meantime if people can upgrade to 6.1 to test it out, please give it a try and report back:
If it doesn’t work right away, try removing regenerating lockfiles.
I was able to get this working on react 17 by turning off the new JSX transform.
In the tsconfig
And add
import * as React from 'react';in all JSX files as needed. After that, you can wipe the tears off your keyboard 🙍♂️Thanks @dburles we’re trying to get it back into
latestnow 😅Ta-da!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.27 containing PR #12874 that references this issue. Upgrade today to the
@latestNPM tag to try it out!@thany unfortunately we can’t backport it easily. instead we’re expediting the 6.1 stable release, due in a week or so.
+1,
--no-dllworked for me with React 17 as wellJeepers creepers!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.1.0-alpha.30 containing PR #12908 that references this issue. Upgrade today to the
@nextNPM tag to try it out!Closing this issue. Please re-open if you think there’s still more to do.
Thanks @shayc ! Will check it out later today
@shilman it turned out not to be the actual reason, but is worth fixing anyway
@shilman The reproduction with React experimental I posted works on 6.1.0-alpha.31
@dburles thanks for the repro. seeing same as above ☝️ – works with yarn fails with npm. not sure what to do other than the workaround. suggestions welcome!
@shilman try this repo, it replicates @scurrilus-funke report
https://github.com/shayc/cboard-2
w00t!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.1.0-alpha.28 containing PR #12874 that references this issue. Upgrade today to the
@nextNPM tag to try it out!Closing this issue. Please re-open if you think there’s still more to do.
I’m hoping we can get rid of the DLLs entirely in 6.1. Fingers crossed 🤞
@molebox not AFAIK. @Hypnosphi any ideas here?