DEV Community

Discussion on: Can React state management get any simpler than this?

 
olvnikon profile image
Vladimir

You should take time to consider what problems you're actually trying to solve, and choose tools that actually solve the problems you're dealing with.

That's what I'm saying. Use the right tool. Before using Redux make sure you really need it.

My very rough estimates of React ecosystem state management market share are

So these are just some random statistics from some random guy on the internet. Not saying he is not right though.

Most devs still think that Redux is the only state management library and pick it just because they think so and don't want to learn new technologies. I talked to my colleagues and they simply don't want to consider using other libraries because they believe "Redux is Redux and other libraries are meh". They even didn't try those libraries. Some React devs still use class components over functional with hooks because:

  • projects are legacy and nobody is going to refactor them
  • devs keep classes on purpose because they prefer them

Coming back to my original idea. Use the right tool and be up-to-date with modern technologies.

Thread Thread
 
markerikson profile image
Mark Erikson

FWIW, I'm the primary Redux maintainer. So, sure, feel free to take my comments with a grain of salt, but A) I happen to be an expert on this topic, B) I spend most of my time answering questions about when it makes sense to use Redux, and C) I'm definitely not just "a random guy on the internet" :)

I've established a pretty solid track record of being straightforward and unbiased in my evaluations and responses:

twitter.com/tannerlinsley/status/1...

Mark is a breath of fresh air, right?! He'll forever be at the top of my list for people that I trust to always deliver an objective take on something, regardless of stake or emotion.

Thread Thread
 
olvnikon profile image
Vladimir

Look, I didn't want to offend you and I partially share your opinion. I'm just saying that often Redux is popular because devs don't want to consider any changes in their existing apps and don't want to try new tools in their new projects.

Recently, I have been working on a project that uses Redux but it is just about keeping fetched data. Yes, it is a lot of data but Redux is not needed for that.

Even when it is needed to store some state maybe a custom hook is enough. Tools like Recoil and Jotai (or Xstate if your choice is state machines) can keep the state and even transform it (hello Reselect).

Coming back to my point:

Use the right tool. Before using Redux make sure you really need it.

Thread Thread
 
darlingtonokoriec profile image
Darlington Okorie

I think you're very right. As soon as one becomes a react developer, the very next expectation everyone seems to have of you is that you must understand and use redux. Obviously, redux isn't the only state management tool out there. There are easier and less complex tools out there. Once you get in that for most of your projects you get to use any of the options, like Recoil, useContext and so many others, its like a brush of possibilities.

Thread Thread
 
oliverradini profile image
OliverRadini

To provide some additional context (no pun intended) to Vladamir's comments...

I'm sure some developers are still using Redux because they "don't want to consider any changes in their existing apps and don't want to try new tools in their new projects." Familiarity is an advantage but ought to be weighed against the benefits which alternatives would bring. Sensible developers won't only use Redux because it's familiar, but novelty should not be the only reason to switch.

I'm still someone who uses Redux because I've not yet tried a state management library which provides enough benefit to justify the switch. If I want to tell the people that I work with that we're making the switch away from Redux, I'll be talking to smart people, and they'll rightly want to know why it is that we're making this switch. Right now I don't feel like I could provide an adequately watertight answer.

For all the same reasons, if someone already knows a library like Recoil, they are right to consider why they would switch to Redux, when they know a perfectly good solution to the same problem.

Thread Thread
 
sefrem profile image
sefrem

Every time i work with Mobx i'm so happy about how easy and intuitive it is. Worked with Redux and Effector, but Mobx nails it for me.