question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React.createElement

See original GitHub issue

Hi 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:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:29 (24 by maintainers)

github_iconTop GitHub Comments

4reactions
ctrlplusbcommented, Jul 19, 2016

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

2reactions
developitcommented, Aug 25, 2016

I think we can finally close this since import { createElement } from 'preact/aliases' is now officially a thing in 6.0.0 (beta)!

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Top-Level API
Create and return a new React element of the given type. The type argument can be either a tag name string (such as...
Read more >
What is the use of React.createElement ? - GeeksforGeeks
A react element is a description of what the actual Document Object Model(DOM) element should look like. React.js don't use the browser DOM ......
Read more >
React.createElement
createElement returns an object rather than the DOM element itself is because React operates a Virtual DOM. We will cover the virtual DOM...
Read more >
React Create Element - React Without JSX - KnowledgeHut
Let's Explore the Important React Component “React Create Element”. A Step-by-step Guide on How to Create React createElement Without JSX.
Read more >
Intro to React.createelement method with examples - Reactgo
React.createElement() method takes the three arguments type , props ,children. type: Type of the html element or component (example : h1, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found