Skip to content
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

React should *only* be a peer dependency #70

Open
timothyarmes opened this issue Oct 22, 2020 · 3 comments
Open

React should *only* be a peer dependency #70

timothyarmes opened this issue Oct 22, 2020 · 3 comments

Comments

@timothyarmes
Copy link

I've just upgraded to React 17, and my code is now failing due to a this 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

Running npm ls react (as suggested here: https://reactjs.org/warnings/invalid-hook-call-warning.html) tells me that frontend-collective-react-dnd-scrollzone is pulling in React 16.

If you see more than one React, you’ll need to figure out why this happens and fix your dependency tree. For example, maybe a library you’re using incorrectly specifies react as a dependency (rather than a peer dependency).

You are specifying React as a peer dependency, but you're also specifying it directly in devDependencies. Can you please remove the direct dependency?

@benatshippabo
Copy link

npm devDependencies aren't installed when you npm install a package https://github.com/npm/npm/blob/v6.1.0/doc/files/package.json.md#devdependencies

@kylios
Copy link

kylios commented Apr 15, 2021

I have the exact same error in my application. I would also like to upgrade to react 17. What's weird is that even when I downgrade react to a compatible version, this package still pulls in its own copy.

$ npm ls react
[email protected] /client
├── [email protected] 
└─┬ [email protected]
  └─┬ [email protected]
    └── [email protected] 

@JCMais
Copy link

JCMais commented May 2, 2021

If using Yarn, resolutions can be used as a workaround:

  "resolutions": {
    "**/frontend-collective-react-dnd-scrollzone/react": "^17.0.2",
    "**/frontend-collective-react-dnd-scrollzone/react-dom": "^17.0.2"
  }

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

No branches or pull requests

4 participants