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

Duplicate Reacts due to Lerna Monorepo? #18

Closed
phoniks opened this issue Nov 17, 2020 · 4 comments
Closed

Duplicate Reacts due to Lerna Monorepo? #18

phoniks opened this issue Nov 17, 2020 · 4 comments

Comments

@phoniks
Copy link

phoniks commented Nov 17, 2020

I'm running into the issue with hooks described here - namely that React seems to be having trouble with my hooks, due to multiple versions of React being referenced. I double checked that the first two causes are not at fault - it's not due to calling hooks out of place (I copied your pattern from the metamask demo to be sure), or mismatching versions of react and react-dom (see photo below)

Screen Shot 2020-11-17 at 11 34 07 AM

I also ran the check suggested in the Duplicate React section of the page to see if two different versions of React are being called, and it returned false (meaning there are two different versions being called). It seems like there are a few suggested solutions for this:

I'm trying to lean away from the custom webpack config, since I started the project with CRA, and would prefer to avoid ejecting if possible. I'm leaning towards the npm-link-shared solution, since it specifically mentions Lerna. Is there a tried and true solution to this issue?

@OR13
Copy link
Member

OR13 commented Nov 17, 2020

The package structure for this repo is a bit hacky, we have been waiting for a TSDX mono repo template to refactor.

Seems almost ready to be tackled:

jaredpalmer/tsdx#778

I'm not sure how to address your specific issue other than pointing to a working create react app example:

... I would recommend either copying one of those as a starting point, or using the yarn resolutions suggestion.

@gjgd
Copy link
Contributor

gjgd commented Nov 17, 2020

Thanks for reporting!

Can you provide steps to reproduce this issue?

It is possible that it is related to yarn and the way it handles package resolution, which is different than npm
The lib should work regardless of which package manager people use, but we only tested it with npm. As temporary fix have you tried to install and run the project using npm?

@phoniks
Copy link
Author

phoniks commented Nov 17, 2020

I'm using npm already. I'm trying out the yarn resolution approach - if that doesn't work I'll see if I can provide steps to reproduce - or better yet, you can clone the repo here. But I don't think I've checked in these changes yet. At the moment homebrew update is hogging my CPU at the moment so as soon as that finishes I'll push them.

@phoniks
Copy link
Author

phoniks commented Nov 17, 2020

Yep... looks like the yarn resolutions solution fixed it! Thanks for the help guys!

@phoniks phoniks closed this as completed Nov 17, 2020
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

3 participants