breadadams / scroller-motion

🛹 Elegant motion scrolling for React
https://scroller-motion.js.org
MIT License
67 stars 5 forks source link

“more than one copy of React” error when running locally #2

Closed rijk closed 4 years ago

rijk commented 4 years ago

Hi, I am trying to clone this package to create some PRs. But when I run it (after building), I keep getting this Next JS error:

I've asked the question on the Next forums as well, but maybe you know a way to work around this?

breadadams commented 4 years ago

@rijk I just ran into this on another project, the solution was the suggestion from the React docs at the bottom of this section: https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react

Assuming myapp and mylib are sibling folders, one possible fix is to run npm link ../myapp/node_modules/react from mylib. This should make the library use the application’s React copy.

I think that's how I resolved this error with scroller-motion too, just comment if it doesn't do the trick 👌

rijk commented 4 years ago

Amazing. I would have never thought of that, but it worked! 👏 Next time I'll remember to check the React docs, haha.

PRs incoming 👾