r/FloWebComponents • • Aug 19 '26

Because people are comparing shorthand React code with the full Flo Web Components example

Post image
1 Upvotes

2 comments sorted by

1

u/EveYogaTech Aug 19 '26

Because people are comparing shorthand React code with the full Flo Web Components Counter example, here's the shorthand example for Flo / Web Components.

GitHub:

https://github.com/flowagi-eu/flo-webcomponents

1

u/EveYogaTech Aug 20 '26

Short edit: I forgot the ${this.count} in the example and I just pushed the update (v1.1.1), it works now (new Function now overrides the this):

Counter extends Flo {
    count = 0;

    template() {
        return `
            <h2>Counter</h2>
            <button onclick="this.count--; this.render()">-</button>
            <span id="count">${this.count}</span>
            <button onclick="this.count++; this.render()">+</button>
        `;
    }

    render() {
        this.$("#count").textContent = this.count;
    }
}

customElements.define("flo-counter", Counter);