News for hackers. Stuff that matters.
Re:Alternatives to JSX by bennypowers on Monday February 25, 2019 @12:17PM (#19247275)
Why JSXBelPack when you can

  import { html, render } from 'https://unpkg.com/lit-html';

  const benefitTpl = ({name, desc}) => html`
    <dt>${name}</dt>
    <dd>${desc}</dd>
  `;
  
  render(html`
    <lit-rocks>
      <dl>${benefits.map(benefitTpl)}</dl>
    </lit-rocks>`, document.body)

And updates are fast without any VDOM overhead.
Re:Alternatives to JSX by zemptime on Monday February 25, 2019 @01:10PM (#19247842)
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

Re:Alternatives to JSX by tracker1 on Monday February 25, 2019 @04:49PM (#19249796)
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.
Re:Alternatives to JSX by zemptime on Monday February 25, 2019 @05:24PM (#19250058)
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
Re:Alternatives to JSX by spankalee on Monday February 25, 2019 @06:51PM (#19250659)
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.