3 ms·
I got into React initially because I could write React components and put them into my HTML where a dynamic component was needed. This was a stark contrast to s
by kerkeslager 3y ago
I got into React initially because I could write React components and put them into my HTML where a dynamic component was needed. This was a stark contrast to stuff like Angular or Ember at the time, which would force me to write the whole page in their framework, abandoning basic HTML which worked a lot better for much of the page. Put another way, when I got into React, it was a good tool for writing multi-page applications with some interactivity on each page, when all the other tools were forcing you into single-page applications.
React is still a good tool for writing MPAs, if you can get your team to stick to it. But unfortunately, if you aren't careful, React has become an infectious disease and slowly eats your whole frontend, even where it's not necessary and in fact, counterproductive. Pages which initially had a component or two, slowly are completely rendered in React, and when this happens to enough pages, someone starts wondering why your site isn't an SPA. It's hard to steer teams away from this, because the short-term benefits always seem tantalizing, and few people stay at jobs long enough these days to grok the long-term downsides.
I've started to think having a JS build step (beyond bundling/minification) at all is the original sin here, and lately I've been doing a lot of my work with just vanilla JS and web components. Web components have their downsides which I've criticized elsewhere, but at least they aren't all-consuming. I've also been playing around with a few lightweight frameworks which don't require a build step like alpine.js and lit.js, but haven't committed to one for a production project yet. The biggest downside to this is that there aren't good tools for automated testing without a build step (that I know of! If you have some please mention them).
- thex10 3y ago> React is still a good tool for writing MPAs, if you can get your team to stick to it. But unfortunately, if you aren't careful, React has become an infectious disease and slowly eats your whole frontend, even where it's not necessary and in fact, counterproductive. Pages which initially had a component or two, slowly are completely rendered in React, and when this happens to enough pages, someone starts wondering why your site isn't an SPA. This started happening to me this year. And all the other senior devs who know better happen to be gone from this project, so I'm alone having to convince these junior engineers (working on a very large non-JS-backend web application mostly with content pages!) that SPAs are not the ultimate solution to all. It's so frustrating.
- err4nt 3y ago"there aren't good tools for automated testing without a build step" For our vanilla JS we use browser-based tests which we can check in any browser anywhere any time, and which can also be automated and measured with a headless browser from the command line. And we have also used Node and had even more luck with Deno for testing individual functions and libraries which may get used on the frontend! Hope that helps!