4 ms·
From the comments I see here, it seems like many people expect the Web Components API to be a complete replacement for a JS framework. The thing is, our framewo
by gitaarik 3y ago
From the comments I see here, it seems like many people expect the Web Components API to be a complete replacement for a JS framework. The thing is, our frameworks should start making more use of modern web APIs, so the frameworks will have to do less heavy lifting themselves, so they can become smaller, so our projects are dependent on less framework code.
Lit [0] for example is doing this. It's a very small library, making use of the Web Components APIs. Using Lit is very similar to using React. Some things work different, and you have to get used to some web component specific things, but once you get it, I think it's way more pleasant to work with than React. It feels more natural, native, less framework-specific.
For state management, I created LitState [1], a tiny library (really only 258 lines), which integrates nicely with Lit, and which makes state management between multiple components very easy. It's much easier than the Redux/flux workflows found in React.
So my experience with this is that it's much nicer to work with, and that your total project size is much smaller.
[0] https://lit.dev/ https://lit.dev/
[1] https://github.com/gitaarik/lit-state https://github.com/gitaarik/lit-state
- troupo 3y ago> The thing is, our frameworks should start making more use of modern web APIs, so the frameworks will have to do less heavy lifting themselves They already do that wherever possible. However, web componens provide almost exactly zero value to frameworks. You could ask a simple question: why did the authors of Vue, Svelte and Solid started as staunch supporters of web components (and even modeled early versions of their frameworks after them), and why are they now at best indifferent and at worst actively hostile towards web components? > It feels more natural, native, less framework-specific. If you ignore all the framework-specific things like custom template DSL, custom JS DSL, custom functionality like contexts and the new custom compiler, it's very native.