I use to build websites before react, so I know how to, but I love react. To me it’s setup (and I’m one of those who still use classes) is basically how my brain would organize them before while states keep all the different data stores and api calls nicely abstracted and contained. I honestly don’t know why you’d want to not use it (or some equivalent, though I don’t yet know any.)
> I honestly don’t know why you’d want to not use it
It’s big and it’s slow when compared to other frameworks and particularly when compared to no framework at all.
I think the important takeaway is that there is no single answer here: different sites have different needs. If you’re making a highly interactive site people will sit on for a long time (say, Gmail) then React’s downsides will matter very little. But if you’re making a “one and done” single page, or a site where the vast majority of the page is static content (e.g. a blog) React is wasteful: a wasteful addition to the page download size and a wasteful process of serialising prop data and hydrating a bunch of components that never see their content change once. It doesn’t matter a whole lot on a desktop machine but try profiling on a low powered Android device, the Chrome performance burndown chart is sobering reading. Even on the server, too… I’ve run into issues before now running React SSR on high traffic web sites.
When making a highly interactive web app a framework like Svelte is smaller, performs better and is a joy to use (a matter of opinion of course). At the very least I’d ask “why not Preact?” when starting a project: it does 90% of what React does at a tiny fraction of the size. That Facebook hasn’t made any meaningful progress in shrinking React shows that it isn’t really a priority for them.
So what’s an alternative to react for simpler websites like blogs? Surely the answer isn’t to just go for vanilla js and html? There’s a lot of differences between browsers and a lot of abstraction that lets me just get to work in react. I’ve built a couple of blogs, using react for the frontend, and I didn’t see anything wrong with that.
Yeah same. I remember when I started messing around with web front-end, I wanted to do pure HTML/CSS/JS, but I found it doesn't really work on web since there's all these little browser fragmentation issues you have to contend with.
So I added JQuery, which was fine, but you still had to build a lot on top once you start building something web-application like.
I tried Angular when that came out, but that felt like it was a little too heavy and opinionated, sort of like a "rails for the front-end".
Then finally React just seemed natural to work with. I could finally build fairly re-usable components, and you had the behavioral logic and state neatly packaged with the "view" definition. It seems like the first time someone had really nailed it with a structure for web front-end, and like that's the way it should have worked all the way along.