4 ms·
My time is currently divided between an Angular project and a "no framework" project, so it's been some time since I touched JSX but we are talking about the di
by rvense 2y ago
My time is currently divided between an Angular project and a "no framework" project, so it's been some time since I touched JSX but we are talking about the difference between:
<MyThing><div class="thing--contents">"Hello"</div></MyThing>
versus
const div = document.createElement("div");
div.innerText = "Hello";
div.classList.add("thing-contents");
const wrapper = thingFactory(div);
Aren't we? It just adds up very quickly is what I'm saying.
- meiraleal 2y agoerr... no? Example using Lit and Template Literals: html`<div class="thing-contents">Hello</div>`; Example using only web components: shadow.innerHTML = `<div class="thing-contents">Hello</div>`;
- rvense 2y agoRight, JSX is not the only way of accomplishing a better syntax for dynamic HTML. I was just saying that I do occasionally do things entirely by hand in Javascript with createElement, and it works for a quick thing but it is actually definitely a thing that warrents bringing in some alternative.
- jampekka 2y agoI was referring to React's createElement-function (and assigning it to const e for ergonomics). const div = e("div", {className: "thing-contents"}, "Hello") Or with coffeescript div = e "div", className: "thing-contents", "Hello" Or with coffeescript and simple Proxy wrapper: div = @div class: "thing-contents", "Hello"