Open bologer opened 3 years ago
This seems like more of a question for stackoverflow
rather than here but I'll share my opinion.
If you're embedding your code not through an iframe
and your code may run on sites already using react
, you'll probably need to state react
and react-dom
as peerDependencies
and not as dependencies
. For sites which don't include react
already, you'll have them as a dependency.
At the very bottom of "Invalid Hook Call Warning" page (https://reactjs.org/warnings/invalid-hook-call-warning.html) it says the following:
However it has no explanation on how to ensure there is no collision between multiple React instances.
I am building an embeddable React widgets and very recently I matched the following error:
Which decodes to the following error message:
After some analysis, 1) is not true, both react and react-dom are matching, 2) rules of hooks are not broken (useMemo() at the very top of functional component), 3) most likely related to it.
The third point I can't control, because website can have various React widgets on the same page which developed by other companies.
I check the following thread but it didn't help me. And it seems to be an issue for some users as well.
What to do in this case?