1.0.0 • Published 6 years ago

babel-plugin-convert-react-type-comparison v1.0.0

Weekly downloads
4
License
-
Repository
-
Last release
6 years ago

React Hot Loader patches REACT on the fly to make createElement creates an instance of a proxified REACT class, enhanced with hotloading capabilities. As a side effect, this kind of code will allways return false :

var foo = return foo.type === MyComponent

because foo is based on a proxi of MyComponent class. Bytheway, in production, this code will return true.

To make the comparison works in dev mode, a solution is to compare the type of the element to the type of a newly created componnent, and not the base class : return foo.type === ().type will work

That's the purpose of this babel plugin. It replaces every expression like { foo.type === MyComponent } by { foo.type === ().type }