3 ms·
> A framework component is effectively a reusable block of code. I think that, for me as a newcomer to front-end development, this is the biggest takeaway: a f
by lelanthran 3y ago
> A framework component is effectively a reusable block of code.
I think that, for me as a newcomer to front-end development, this is the biggest takeaway: a framework component is a reusable block of javascript while a webcomponent is a reusable HTML element.
As a newcomer[1] it does not make sense to even learn the front-end frameworks. As an example, the time spent in learning the entire framework simply so I can 'watch' an element's value for changes, or propagate an element's changed value to other elements is going to be order of magnitudes greater than simply writing 3 custom elements that monitor and propagate values for any child element.
(PS. I like your post. I think a followup blog post with two concrete examples may make sense in refining your thesis:
Example 1. This is a popular React mechanism to do $FOO, here's how it is easier in a webcomponent.
Example 2. This is a complex webcomponent, here's how it is easier in React.)
[1] One who is not looking to put "react", "vue", etc on their CV.
- SkiFire13 3y ago> than simply writing 3 custom elements that monitor and propagate values for any child element. I feel like you're underestimating how easy this is to skrew up.
- lelanthran 3y agoYou're probably correct in your assessment of my estimation. However, it's far far easier for a newcomer to screw up when approaching react or cue than when approaching a custom html element. Time will tell as I use my experiment in more domains, more often and in larger apps.
- mst 3y agoI rather like https://lit.dev/ https://lit.dev/ for web components so far. For the reactivity stuff, you might want to read https://frontendmasters.com/blog/vanilla-javascript-reactivity/ https://frontendmasters.com/blog/vanilla-javascript-reactivi... - it shows a bunch of no-library-required patterns that, while in a number of cases I'd much rather use a library myself, all seems at least -basically- reasonable to me and will probably be far more comprehensible to you than whatever I'd reach for, and frameworks are always much more pleasant to approach after you've already done a bunch of stuff by banging rocks together first.
- DrScientist 3y ago> a framework component is a reusable block of javascript while a webcomponent is a reusable HTML element. Web components/custom elements are reusable behaviours/functions - which can contain custom js, all bundled as a reusable HTML element. Think of it a bit like an object in an object orientated programming language - the object has both data/state (DOM) and code/functions to manipulate that state.