3 ms·
> uses plain JS for building up the DOM tree (normal functions, no JSX or template tags) body({ oncreate: (e) => { console.log(e, 'was
by madeofpalk 6y ago
> uses plain JS for building up the DOM tree (normal functions, no JSX or template tags)
body({
oncreate: (e) => {
console.log(e, 'was just added to the DOM')
}
}, 'Hello world!'),
heh. I find it mildly funny when people recreate JSX from from first principles
- blacktriangle 6y agoI find it funny that JSX even exists when writing helpers to build html with functions is such a trivial exercise and easy to read, but nope, lets add in some wonky XML with weird corner cases.
- williamdclt 6y ago> and easy to read Very arguable. I'll take "wonky XML" over JS function calls any day for readability, and apparently most people would too given that they write JSX rather than use `React.createElement` and that all major frontend view libs (angular, react, vue, svelte, mithril...) offer XML-like templating and people overwhelmingly use it.
- SahAssar 6y agoJSX basically compiles down to function calls, so this is more like taking the JSX out of the loop. In react the equivalent JSX would basically compile to React.createElement("body", { oncreate: (e) => { console.log(e, 'was just added to the DOM') } }, 'Hello world!'), which does not seem that different, right? If you want to you can use JSX with skruv as long as you tell the JSX compiler to use `h` instead, in which case it will produce this: h("body", { oncreate: (e) => { console.log(e, 'was just added to the DOM') } }, 'Hello world!'), which works with skruv.
- madeofpalk 6y agoYes this was kind of my observation.
- dang 6y agoCan you please follow the site guidelines when posting to HN, and the Show HN guidelines when posting to Show HN threads? Your comment breaks both of them, and is an instance of the snarky, dismissive culture that we're trying to avoid here. I'm sure you didn't mean it that way, but these things get upvoted, and condition the entire thread and ultimately the ecosystem. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/showhn.html https://news.ycombinator.com/showhn.html