Thanks, Sashi.
No idea what's wrong with it, sorry. I have never encountered the issue you're having.
I believe its caused due to multiple copies (not versions) of React.. I do see multiple copies of react
So, when rendering a view in the CRA, the app thinks there are multiple copies or React and hence the invalid hook call..
Not sure how to resolve this..
You're absolutely correct! In fact I had this problem myself but couldn't recognise it at first from invalid hook call.
Add below externals Webpack settings for lib1 and lib2 so that they don't bundle its own React but use whatever create-react-app1 is using.
externals
webpack.common.js
module.exports = { ... externals: { react: { root: "React", commonjs2: "react", commonjs: "react", amd: "react", }, }, };
i did add react and react-dom to the externals in lib1 and lib2...some reason, when i do the npm install at the root, i do see react and react-dom in the node_modules folder at the root..
i'll give it another shot...appreciate your comments..
No worries. I know it can be tricky.
Maybe try fixing for a single external lib1 and /create-react-app1 firstly. You might be very close to solving this but there's too many moving parts.
Good luck!
If its not much trouble would it be possible to post your example on github ?
Good idea. I'll do it this weekend.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks, Sashi.
No idea what's wrong with it, sorry. I have never encountered the issue you're having.
I believe its caused due to multiple copies (not versions) of React..
I do see multiple copies of react
So, when rendering a view in the CRA, the app thinks there are multiple copies or React and hence the invalid hook call..
Not sure how to resolve this..
You're absolutely correct! In fact I had this problem myself but couldn't recognise it at first from invalid hook call.
Add below
externals
Webpack settings for lib1 and lib2 so that they don't bundle its own React but use whatever create-react-app1 is using.webpack.common.js
i did add react and react-dom to the externals in lib1 and lib2...some reason, when i do the npm install at the root, i do see react and react-dom in the node_modules folder at the root..
i'll give it another shot...appreciate your comments..
No worries. I know it can be tricky.
Maybe try fixing for a single external lib1 and /create-react-app1 firstly. You might be very close to solving this but there's too many moving parts.
Good luck!
If its not much trouble would it be possible to post your example on github ?
Good idea. I'll do it this weekend.