Various sub-projects do have react and react-dom as dependencies resulting in hook-errors
See original GitHub issueDescribe the bug Multiple react and react-dom dependencies inside of @storybook lead to the following type of error:
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:
- You might have mismatching versions of React and the renderer (such as React DOM)
- You might be breaking the Rules of Hooks 3. You might have more than one copy of React in the same app
To Reproduce e.g. https://github.com/storybookjs/storybook/blob/next/lib/components/package.json
or
git clone https://github.com/jookshub/storybook_cra_tsx.git
nvm use
npm i
npm run storybook
-> brokennpm run storybook-fixed
-> working
Expected behavior react and react-dom should be peer-dependencies in all package.json files of @storybook or configured in a way that does not interfere with react hooks.
Screenshots
Additional context See related solution for old issue: https://github.com/storybookjs/storybook/issues/4691#issuecomment-442581382
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (4 by maintainers)
Top Results From Across the Web
ReactDOM – React
ReactDOM. The react-dom package provides DOM-specific methods that can be used at the top level of your app and as an escape hatch...
Read more >How to avoid `loaded two copies of React` error when ...
Solution: All you have to do is link the react and react-dom in your component to that of parent project's node_modules folder. Go...
Read more >Add a Dependency to React in package.json for a ... - Pluralsight
This file keeps track of all the different kinds of dependencies you are using in your project in JSON format. There are essentially...
Read more >How to Build a React Project with Create React App in 10 Steps
node_modules is a folder that includes all of the dependency-related code that Create React App has installed. You will never need to go...
Read more >How To Set Up a React Project with Create React App
By the end of this tutorial, you'll have a running React application ... necessary files into a new directory and install all dependencies....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
related: https://github.com/storybookjs/storybook/pull/11628
I believe this was fixed in #12972. Closing.