You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using React components inside a meteor package in a meteor 3 project will result in a React warning about multiple instances of React in the same app. It's a regression since it works fine with meteor 2.
you should see a grey line where you can click and enter some text
open the developer console and you should see nothing
Test with meteor 3 (not working)
open a terminal and run the following commands:
./bin/run3
open a browser and go to http://localhost:3000/
you should not see the grey line
open the developer console and you should see the following output:
Warning: 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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
You'll see that there's 2 instances of react-dom in the projet if you run the following command:
I could reproduce this as your description suggests. The strange part is that we didn't have any more reports on this... I did some debugging but I couldn't find the root cause of this. I'm going to have another go at it later.
@paulincai i never did meteor npm package so not sure how to take it down as a local npm package.
this is a minimal reproduction repo to make it easier to debug. But in our project, the sakod:core meteor package contains tons of meteor stuffs that we want to keep in a meteor package.
ok, I think your problem could be related to this: facebook/lexical#5996 and not related to Meteor bundling tools.
This explains how to depend, in a Meteor package, on a local NPM package: meteor/guide#682
To create a local NPM package, just copy an NPM package in a local folder in your project and reference it in either the global package.json of your project "@pampam/packagename": "file:folderLocation/FolderOfThePackageWhichContainsPackageDotJson", or in a Meteor package.
If it's a lexical issue, since we use the same version, why it works with Meteor 2 and not Meteor 3? Could it be due to a change with node version or node modules management?
We created a repo to reproduce this issue > https://github.com/acemtp/meteor3reactbug
Using React components inside a meteor package in a meteor 3 project will result in a React warning about multiple instances of React in the same app. It's a regression since it works fine with meteor 2.
How to reproduce
Test with meteor 2 (working as expected)
open a browser and go to
http://localhost:3000/
you should see a grey line where you can click and enter some text
open the developer console and you should see nothing
Test with meteor 3 (not working)
open a browser and go to
http://localhost:3000/
you should not see the grey line
open the developer console and you should see the following output:
You'll see that there's 2 instances of
react-dom
in the projet if you run the following command:One in the
node_modules
and one in the meteor package and it explains the React warning (You might have more than one copy of React in the same app).Doing the same test with meteor 2 will work as expected and
find . -name react-dom
will only return thenode_modules
instance.I really have no idea why this is happening, is it a changes in the meteor building system or in npm?
The text was updated successfully, but these errors were encountered: