DEV Community

Discussion on: Web Components using LIT-HTML and LIT-ELEMENT

Collapse
 
jwp profile image
John Peters • Edited
  • Uses a combined imperative declarative style. JSX is not needed.
  • Has a render function just like React.
  • Uses tagged Template literals
  • Supported by all browsers natively
  • Ultra Fast as only the context is tracked not the element.
import {html, render} from 'lit-html';

// A lit-html template uses the `html` template tag:
let sayHello = (name) => html`<h1>Hello ${name}</h1>`;

// It's rendered with the `render()` function:
render(sayHello('World'), document.body);

// And re-renders only update the data that changed, without VDOM diffing!
render(sayHello('Everyone'), document.body);