by cjonas · 5y ago · 0 comments
Before react I hated UI programming so much. But the way react deals with state makes it so much easier to build and maintain complex applications.
All you have to do is define how your application responds to any given state and provide explicit controls for asking to update that state. If you do that correctly, your application will be predicable and easy to reason about.
The biggest challenge is it's just not the normal imperative programming model that most devs are used to. It takes time and understand to do correctly, but what doesn't?
I'll readily admit to being a passionate radical about this stuff. The things I have to say are basically just a bunch of bomb throws and I don't feel this is the appropriate place nor do I have the requisite time.
Rest assured, I've put in a considerable amount of time and effort into my thoughts on the matter and we'll likely disagree, but let's not do that here.
I'll think about how to best present it gently and prepare something.
The stuff I have is really much more for the STS people who think Silicon Valley should literally be dismantled brick by brick. That's a different audience than my fellow startup engineers (I've got my feet in many conflicting camps)
When someone has a strong negative take on something I thought was great, that's a perfect opportunity to learn deeply about trade-offs or concerns I might not be fully aware of.
If nothing else, it gives me an opportunity to evaluate potential issue, put guards in place to reduce the impact, and arms me to defend my choices should the need arise.
Real question; not being snippy...
I didn't think React had any state management included. A lot of people I've spoken to seem to use Redux, a third party library for handling state.
Is my understanding incorrect?
However, that _is_ limited in that you can only access state inside the current component, or pass it down the tree as props/context. If you need to access data broadly across the component tree, or the data itself does not lend itself to a tree-shaped usage pattern, or you need to minimize the number of components that re-render when you update, or you need to use it _outside_ the component tree, then you may want to look at an external state management library.
I've talked about the tradeoffs in these approaches numerous times:
https://blog.isquaredsoftware.com/2021/01/context-redux-diff...
https://changelog.com/posts/when-and-when-not-to-reach-for-r...
https://blog.isquaredsoftware.com/2020/05/blogged-answers-a-...
All that said: React makes writing an application with any meaningful amount of complexity _vastly_ easier to do than trying to do it with either preceding UI frameworks (AngularJS 1.x, Backbone, etc) or jQuery. It isn't perfect, but it's well-suited for a wide range of application development use cases.
Redux takes that to the next level but is based on similar principles of "reactive" programming. For complex state heavy applications it's extremely powerful, but often overkill for many smaller applications.
But I also think 'react' means two different things. One the one hand, it's "just a library". In industry, it tends to mean... react + JSX + react-router + redux + react-this + react-that + react-redux-this-and-that all tied together with create-react-app. Plus its own command line tools, and browser plugins. It starts to feel very much like a framework then, if not a platform of its own.