Live data from Hacker News

Show HN: I made helpers for Web Components

github.com

11–13 of 13 posts

Re: Show HN: I made helpers for Web Components

#11

Lit-html is such a great piece of code. It should be part of web components standard.

I agree, but I feel like there is something still missing.

The render lifecycle works best when everything is already in memory. Fetching data based on state updates is tricky. Tasks are supposed to fill this gap, but are still a bit clunky:

https://lit.dev/docs/data/task/

The most reliable approach for me has been to batch api calls and state updates manually in a separate method on the element, and let lit focus only on rendering.

Re: Show HN: I made helpers for Web Components

#12

I'm convinced that plain web components are now the best solution for the front end. That said, I don't think any libraries are needed to use them well. Also, I hope that people don't try to implement 'reactivity' in the React way for Web Components... The correct way to handle state changes in Web Components is by changing their attributes and setting up an attributeChangedCallback inside the component (with an obse…

> Also, I hope that people don't try to implement 'reactivity' in the React way for Web Components... The correct way to handle state changes in Web Components is by changing their attributes and setting up an attributeChangedCallback inside the component

You don't want to update the component on every attribute change as the component might have multiple attributes so you need to batch the changes. Then when changing you also don't want to discard the whole rendered component and render it again. With those 2 things you have React, or much better, without a vdom: LitElement + Lit-html.

Post reply on HN