Wednesday, September 21, 2022

The perils of React

This was a great article on React that popped up in my Reddit feed:

I have my own feelings on React and the generally complex state of front-end web development today.  

I've worked on a lot of front-end code since 2013; we started bringing in React around 2015 and I immediately found it just really confusing. I've got a little better handle on it now, just built my own website (!) with modern(-ish?) React and Typescript, which seems like generally a good combo for medium-complexity sites. I do like how the code looks with functional components and hooks, and I was able to find a library that wraps my map provider's components with React objects; it generally works pretty well.

But I agree with a lot of the points in the article, especially:

- Having to know the "Rules of Hooks" is bad; the rules should be more intuitive, or easier to spot or have called out at development time

- Having to read a dissertation on a hook to use it "properly" is bad

- Everybody's opinion of "properly" seems to be different

- The framework is bad at letting me know I'm doing it wrong

- Having to list out dependencies should be unnecessary

- Debugging rendering performance issues is painful, the solutions are usually non-obvious

- Outdated documentation, outdated code bases and packages, outdated Stack Overflow answers are all a huge problem.

And then just generally the whole thing about state management. This is a framework that updates my components based on changing state, but it just does not natively handle state well, for any site that's more complex than a few components. The fact we need to bring in some external package like a Redux to attempt to handle it feels like a massive shortfall.

I was indeed handling this stuff just fine on my own back in the day with MVVM organization and jQuery, and navigating these hurdles often doesn't make React feel like an improvement.

And then yeah, there's the fact that it's a Facebook joint; what if Facebook one day just decides they're going to up and charge to use the license? Doesn't feel far-fetched in 2022 when Meta is seeming to struggle to maintain its relevance.