React.createElement
See original GitHub issueHi there! Question for @developit :
I’m considering to use preact because 3kb for the React API is just amazing. However, react’s ecosystem has a lot more tools at the moment especially react-hot-loader
and enzyme
for testing, which are not compatible with preact or preact-compat.
In order to benefit from both of both worlds, I’m importing react
and react-dom
in the code, use original react in development, and use an alias on preact
when really making the bundle. This way I realized that createElement
was simply not in preact, thus making it not a drop-in replacement of react. I think this is really unfortunate, in my case, and as this could have encouraged people taking advantage of preact.
Don’t you think exporting createElement
as an alias of h
would be good?
I considered the .babelrc
jsx pragma solution but this is really inconvenient as I’d like to manage choosing react or preact from my webpack configs.
NB: if you have better options to suggest me in terms of enzyme
/hot-loader
tooling I’m definitely interested 😃
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:29 (24 by maintainers)
Top GitHub Comments
I have created a simple example of how to use native HMR of webpack 2 with preact/preact-compat.
https://github.com/ctrlplusb/preact-compat-hmr
I think we can finally close this since
import { createElement } from 'preact/aliases'
is now officially a thing in 6.0.0 (beta)!