DEV Community

Discussion on: Why I use Web Components - My use cases

Collapse
 
bennypowers profile image
Benny Powers 🇮🇱🇨🇦 • Edited

Great write-up. Here's an example of your counter component written using hybrids. Devs might choose hybrids if they are looking to factor an app with a (mostly-)functional, highly composable component model.

import { define, html } from 'hybrids';

const inc = host => host.count += 1;

const MyCounter = {
  count: 0,
  render: ({count}) => html`
     <label for="button">${count}</label>
     <button id="button" onclick="${inc}">Increment</button>
  `
};

define('my-counter', MyCounter);
Collapse
 
smalluban profile image
Dominik Lubański

I didn't know that I have an ambassador of the project :) It so cool to see that other people uses your work.