by coding123 · 6y ago · 0 comments
I think one thing I would love to see from JSX is for it to start growing outside of the React world. Vue seems to be trying. Until React came along, we really had no compile time checking on templating languages at all. I think the reason for that, is, in part, because the templating aspect was always thought of as "dirty" that you shouldn't mix JS and the view parts. I think React debunked that notion. I've never been as productive in creating UIs as I have when I'm working in React. And a lot of that is because I call my backend, I get a typed object back, I tell the UI to use <div>{response.medication.firstName}</div> and if we ever change the structure of medication? I get full help from the compiler that that view will no longer work... If you haven't used React you might not get the full power of that.
Even if I am a React fan, it doesn't mean I don't think other frameworks won't ever take over, but I think at this point, the one that may eventually eclipse React is probably going to have native JSX support.
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.
html`
<ul>
${items.map((i) => html`<li>${i}</li>`)}
</ul>
`
...so I don't understand the critique.