question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Various sub-projects do have react and react-dom as dependencies resulting in hook-errors

See original GitHub issue

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

  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

To Reproduce e.g. https://github.com/storybookjs/storybook/blob/next/lib/components/package.json

or

  1. git clone https://github.com/jookshub/storybook_cra_tsx.git
  2. nvm use
  3. npm i
  4. npm run storybook -> broken
  5. npm 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 Bildschirmfoto 2020-07-14 um 22 16 52

Additional context See related solution for old issue: https://github.com/storybookjs/storybook/issues/4691#issuecomment-442581382

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ndelangencommented, Jul 22, 2020
0reactions
shilmancommented, Nov 4, 2020

I believe this was fixed in #12972. Closing.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found