Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yeah, agreed. React and JSX really shines with a good component library, and the key word with react is composable. I don't know that, by itself, better syntax for HTML-in-JS would advance the state of the art. Instead of having divs and spans everywhere, they're an implementation detail of components.

I can change

    <leftPanel>
        <userInfo>
    </leftPanel>
    <rightPanel>
        <medicationsPanel>
    </rightPanel>
to

    <topBar>
        <userInfo>
    </topBar>
    <leftPanel>
        <medicationsPanel>
    </leftPanel>
Without having to know what html+css tricks topBar is doing under the hood.

Inside of medicationsPanel, there's <medicationsList> which is the `ul`.

    <ul>
        {medications.map(m => {
            <medicationListItem item=m />
        })}
    </ul>
medicationListItem has the `<li>`, with the styling living somewhere inside. Templates, especially in separate files, don't really manage to be composable with the same ease. Leaving the divs and spans and CSS to the lowest levels of the component library does wonders for making the code easier to reason about, and maintain. React code from a few years ago still has some warts, but it's still way less painful to try and pick up than code that was written with traditional templating. (Specifically, the templated project was using `.erb` files.)

React threw out MVC and templates (though some say it's just the V instead), and is worth learning just to feel like it's possible to implement UIs cleanly.



Webcomponents should help with this. Although the current API is not as pleasant to use as react.


They can't and they won't. Because they rely on DOM APIs to do anything useful. Which brings us back to the article.


What does that have to do with having composable components?


Everything.

The only way the vanilla webcomponents are "composable" is through tons of boilerplate code using DOM APIs. You can't even re-create the example with list elements without tearing your hair out when using webcomponents.

It's so bad that any examples showing "composability" immediately give up and use .innerHtml everywhere, and even then it's pretty bad.

It's so bad, in fact, that people do anything to avoid writing vanilla and use lit-html (yay, programming with strings), Stencil, or even Preact (AMP switched to Preact to author components).




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: