sopetrichor / react-photo-collage

MIT License
27 stars 18 forks source link

Hook issues #7

Closed Geofflew closed 3 years ago

Geofflew commented 4 years ago

I get invalid hook errors when I try running this in my react app

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.
bvelasquez commented 4 years ago

Any solution to this?

jackgeorge11 commented 3 years ago

Anyone find any solution to this? Wondering if it is because I am attempting to use react photo collage on react 17.0.1. When I run npm ls react in the terminal I see that there are still unmet dependencies required by the current version of react-photo-collage. Does it have something to do with different versions of react being installed?

zythosec commented 3 years ago

I see the same issue in React 17.0.1. I believe this is because React is specified in dependencies instead of peerDependencies. This causes multiple versions of React to be loaded. See React docs here: https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react A workaround as mentioned in there is to potentially use yarn resolutions if you are using yarn until it is fixed.

jeffreystorer commented 3 years ago

I fixed this by going to the react-photo-collage node module and deleting the react and react-dom modules, which duplicate those installed by create-react-app.

salman-321 commented 3 years ago

I fixed this by going to the react-photo-collage node module and deleting the react and react-dom modules, which duplicate those installed by create-react-app.

i tried by deleting react and react-dom modules, still not working...

sopetrichor commented 3 years ago

I have moved react and react-dom from dependencies to peerDependencies to solve problem caused by mismatching versions of React. Please use the latest version available.