Re:Alternatives to JSX
by bennypowers on Monday February 25, 2019 @12:17PM
(#19247275)
Why JSXBelPack when you can
And updates are fast without any VDOM overhead.
[ Parent
| on HN ]
I'm popping in here to say, I've had people from both Vue and React join my team where we're using lit-html. Transitions have been seamless, mental models map over quite well.
Re:Alternatives to JSX
by hyperpress on Monday February 25, 2019 @01:15PM
(#19247901)
There's so much less cruft and overhead with lit-html, and you get speed that's akin to vanilla JavaScript. As for JSX, I think we can all get used to something non-standard, which after enough time feels normal, but the benefits of a lit-html are so immediately apparent. The transition is super easy.
Re:Alternatives to JSX
by westbrookj on Monday February 25, 2019 @12:21PM
(#19247320)
Yes, this!
Also, don't forget your `?module` at the end of your unpkg link to get that running
Is this doing a full re-render on each change? Having not seen the state management piece... but could be nice for progressive enhancement modules in a server-rendered app. I've done similar in JS.
Nope! It doesn't visit each node like vdom. VDOM visits every virtual node. lit-html looks at only the expressions. That's where a lot of the speed/performance comes from
zeptime's correct. lit-html places markers in the HTML where the expressions are. Then it renders the HTML once, and updates the expressions directly. That's how it avoids a full re-render and avoids building am in-memory VDOM and doing any diffing.