Preact: Without BabelJS - more of a tools question

Created on 3 Apr 2018  路  5Comments  路  Source: preactjs/preact

I am trying to eliminate my need / dependency on transpilers. I've run into a lot of issue during development, time consuming issues, and I frankly don't like this paradigm. But, it is what it is. I know you can do regular javascript classes and not do JSX.

Is there an easier way to convert primarily the render method, to plain javascript, than perhaps the method i was doing of looking at the compiled jsx which gave me this?

I know there is a syntax, for which I need to find a good link on the right format, but frankly, I'd love to find a way to take my jsx render html and put it in the H hyperscript format without too much hassle.

I realize this is not an issue with preact more of a tools question, to use in conjunction with preact. Thank you kindly.

ContactConnect.prototype.render = function render() {
return (0, _preact.h)(
'section',
{ 'class': 'container' },
(0, _preact.h)(
'div',
{ 'class': 'row' },
(0, _preact.h)(
'div',
{ 'class': 'six columns' },
(0, _preact.h)(
'div',
{ 'class': 'mycard' },
(0, _preact.h)(

question

Most helpful comment

Preacts h actually supports children as additional parameters but that doesn't really matter here.

@CoderJason123 if you need to only support browsers that support template literals you could use hyperx.

Here an example using h(), h() with rest params as children and a tagged template using hyperx.

All 5 comments

If you want to use without JSX, using h function inside render is just like using 'React.createElement'. See demo

The only difference is that preact h doesn't take a third argument for children, but treat children as one of the props

Thank you -- so i am familiar with the syntax. But the effort level to convert several jsx pages by hand is not currently worth it to me. I'd like to find a tool to assist me.

Converting JSX to h is what babel does(among other things). I don't think there are other tooling options does this.

You might be right. It looks like Buble gives me a pretty clean format vs Babel. I think this will serve my needs. I can run my jsx thru here and use the end result to a js file. I just hate the reliance on so much tooling required for simple old javascript! Thank you!

Preacts h actually supports children as additional parameters but that doesn't really matter here.

@CoderJason123 if you need to only support browsers that support template literals you could use hyperx.

Here an example using h(), h() with rest params as children and a tagged template using hyperx.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adriaanwm picture adriaanwm  路  3Comments

jescalan picture jescalan  路  3Comments

kossnocorp picture kossnocorp  路  3Comments

KnisterPeter picture KnisterPeter  路  3Comments

matthewmueller picture matthewmueller  路  3Comments