react-lite icon indicating copy to clipboard operation
react-lite copied to clipboard

react-lite doesn't throw errors if ReactLite is loaded twice on page

Open rileylnapier opened this issue 8 years ago • 2 comments

i ran into an issue yesterday where my event handlers were all firing twice. took me long time to debug and i ended up having to revert react-lite. when i reverted, i got this error

Uncaught Error: Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's `render` method, or you have multiple copies of React loaded (details: https://fb.me/react-refs-must-have-owner).

i then was able to realize i had react-lite in 2 different bundles and then fixed my problem and went back to use react-lite.

would be nice to have this error in react-lite too. thoughts?

rileylnapier avatar Jul 20 '17 15:07 rileylnapier

Did you use babel-plugin-transform-react-inline-elements which included regular react?

react-lite is written by ES2015, as a UMD modules, and works with webpack alias, it is hard to load react-lite twice, and it is also hard to check that.

Maybe webpack-bundle-analyzer can help:)

Lucifier129 avatar Jul 21 '17 02:07 Lucifier129

no, my build just creates two bundles for one page and i didn't realize both of them had react bundled. this caused some really weird errors. react throws an error in this situation and react-lite doesn't. just fyi.

rileylnapier avatar Jul 21 '17 02:07 rileylnapier