I don't like how this article moves the goal posts of whether redux fits our use case or not. It has some valid arguments (dev tools) but the overhead of the boilerplate and tooling around redux is just not worth it IMO.
Much better to break your app state into various custom hooks that leverage Context API and the `useReducer` hook.
Not sure what you mean by "moving the goalposts" here.
I'm trying to make a few specific points:
- Redux is not "dead" in the sense that it is still widely used and is continuing to be adopted
- There are definitely many other tools in the React ecosystem that overlap with how you'd use Redux, but the Venn diagrams for the use cases don't entirely match up, and the other solutions don't necessarily have all the capabilities of Redux
- Redux _has_ been over-used and put in apps where it didn't fit well, and I want people to only use it when it makes sense to do so
- Our Redux Toolkit library and React-Redux hooks API make it a lot easier to use Redux
‘ - Redux _has_ been over-used and put in apps where it didn't fit well, and I want people to only use it when it makes sense to do so’. ‘
There are developers working day in and day out in these Redux codebases so our feedback is coming from a real place. There’s a million articles that pushed Redux to the top and got it used in just about everything. Articles just like this one.
This article is literally pushing back against all the reasons why Redux might not be a good fit. There’s very little in it that goes ‘yeah you know what, for this scenario, don’t use Redux’.
- I have no control over the millions of other tutorials that have been written. I can only control my own blog, and the actual Redux docs.
- The question of "When does it make sense to use Redux?" has been answered numerous times already [0] [1] [2]
- I wasn't trying to address the "when?" question in this article. I was trying to answer "is Redux still a viable choice, and how does it compare to other alternatives?"
I've written plenty of 6-10K word blog posts about Redux before that delve into how and when to use it. That wasn't my goal for this post.
There is an odd dynamic that happens in tech: A framework or approach exists for a specific purpose; that framework is used badly or inappropriately by devs who don't fully understand it; those same devs spread the idea that said framework is bad/difficult/insecure and people who use it just don't know what they're doing; some of those devs happen to be "thought leaders" and use their platform to broadcast their misunderstanding as gospel
CSS, SASS, redux, array.reduce, webpack are examples that come immediately to mind from the javascript world. There have been so many throughout the years
So it’s difficult to parse what your observation is providing insight into.
So let’s see how this blame game works, because I have a hunch you want to aim it at people that think Redux is a bad choice.
You are suggesting that people that really don’t like Redux actually don’t know how to use it properly, misuse it, go down that rabbit hole and come out completely jaded by it. They then go on to provide their feedback, to which the obvious dismissive response is ‘well maybe you don’t know what your’re doing’. So the bad mouthing is actually occurring from the other side, no?
For the last few years, any job post you saw related to React, Redux was a prerequisite for probably over 90% of those posts. In other words, Redux was gospel, not the the feedback of naysayers. The mass broadcasting was happening by the framework adopters to the point said framework became ubiquitous.
Lastly, there’s very little feedback about Redux that has to do with people’s understanding of it. Almost the entirety of feedback is coming from usage of Redux and noticing by-products of using it (bloated code base, needless complexity - and this needless complexity criticism is ripe for being sniped by the framework advocates as a symptom of essentially incompetent developers who can’t see the elegance of Redux. The feedback is that it’s not elegant ).
The thought leaders are not the people providing negative feedback in this thread and elsewhere. The thought leaders, the gospel creators in this case are these Redux based articles/advocates that prolifically spread Redux throughout the React ecosystem to the point it became a standard dependency for every app.
In this case, this is a very real situation where it needs serious push back because it spread untethered and unexamined.
One thing I also want to point out, the same way the developer community has a responsibility to evaluate the proper usage of a technology, those who partake in pushing certain technology also have a responsibility of analyzing the impact of what they are evangelizing. One could argue it is irresponsible for influential subsets of the Javascript ecosystem to push a layer of complexity for apps that do not need to make the trade offs for a few features.
@runawaybottle, with sincere respect, you projected a lot of meaning into what I wrote: "You are suggesting that people that really don’t like Redux actually don’t know how to use it properly, misuse it, go down that rabbit hole and come out completely jaded by it."
Nope. Neither implied nor intended.
The article is a reasonable reaction by a redux maintainer to the dynamic I describe. "I don't like using Redux" is a totally valid opinion. "Redux is terrible" is, frankly, not a valid opinion. Neither is it valid for CSS, javascript, React, Vue, Pascal, COBOL nor what-have-you, and yet here we are yet again, letting fickle winds of fashion and facile opinion dictate what should be engineering decisions.
Use redux if your use case applies. Don't use redux if it doesn't. If you find it unwieldy, dont use it. I wish the tech community could leave it there, but they don't.
I'll point out that the Redux team (first Dan Abramov and Andrew Clark, now myself and Tim Dorr) never tried to market Redux as something you _must_ use, and in fact have had to actively spend lots of time telling people to _not_ use it all the time. (Probably one of the only tools in existence where the maintainers have spent more time _discouraging_ its use than _encouraging it, which is a state of affairs that frustrates me to no end.) We've continually tried to provide guidance in the docs as to when it _does_ make sense to use it.
But, as I noted just above this comment: we don't control the rest of the developer ecosystem. All we control is the official docs, and our own blogs and social media comments.
I also want to emphasize that we _haven't_ dismissed people's feedback as "you don't know what you're doing", and in fact have tried to take that feedback into account with our docs and the creation of Redux Toolkit, to guide people in the right direction as they use Redux.
Much better to break your app state into various custom hooks that leverage Context API and the `useReducer` hook.