DEV Community

Discussion on: Why I Stopped Using Redux

Collapse
 
caiangums profile image
Ilê Caian

TL;DR: If you are starting a project from scratch, consider not typing

$ yarn add redux react-redux
Enter fullscreen mode Exit fullscreen mode

Until it's necessary.

How to discover if it's necessary? For a quick discover, ask some simple questions:

  • does it have more than just one page?
  • does it have more than 1 form?
  • does it need to fetch tons of data?

If the answers are "No", consider using Context API or React-Query.

Remember: You are free to use anything you want! Be happy!
Stay home ❤️

Collapse
 
khelnagar profile image
khelnagar

If my answer is yes to all, and I am actually developing a social network like app (somehow FB like), can context API and React built-in state management suffice?

Collapse
 
caiangums profile image
Ilê Caian

It depends! For big amount of data, Context API tend to be slow. Even if you want to go with Redux, consider checking MobX lib and thinking what you really need. There's no silver bullet and sometimes your thrive for using one specific tool to all your needs can drive you to unpleasant places! 😄

Thread Thread
 
khelnagar profile image
khelnagar • Edited

Thank you for your reply.

Sure it depends that’s why I am still thinking. I am not really aware yet of how big data would be or which parts (all or some?)of the app would need the global state so that I can define it is really big, to decide whether to dump Context/hooks.

I more inclined into avoiding Redux as I can see that my current challenges are just prop drilling and updating state globally from anywhere in comp tree, where I see built-in React is enough.

Am I missing future challenges that Redux would solve down the line, and I am not aware of as not grown big yet?

Thread Thread
 
caiangums profile image
Ilê Caian

You can always change from one to another tool, if you need to do so. In my personal opinion we lose too much time advocating for one or another tool instead of experiment and create Proof of Concepts.
There are things that we'll only learn by experience and time. If Context API is ok and you feel that this tool attend all your needs, it's ok to maintain! Just don't be blind to another tools and avoid learning just because someone told you to :smile;

Collapse
 
samwightt profile image
Sam Wight

Probably not, no. The main tools that Redux provides are middleware and dev tools. With middleware, you can integrate things like thunks into your store, making it incredibly easy to fetch data in your app. Dev tools make it very easy to actually see what's going on in your store, something useReducer or useState can't let you do as easily. If you're building any sort of complex application, I'd recommend using Redux at the start to avoid the issues that pop up later if you don't.

Collapse
 
aralroca profile image
Aral Roca • Edited

If the answers are "YES", consider to use Teaful github.com/teafuljs/teaful 🤗

Collapse
 
yashiroquy profile image
UMR • Edited

I built a SPA with more than one routes, and fetch tons of data. After the project started become big, I thought maybe I should try learning Redux. After reading the docs about Redux, I decided to stick with useReducer and context because I understand nothing.

Collapse
 
ug02fast profile image
Arthur Zhuk

I'm using a custom caching solution like react-query at scale pleasantly. Redux is the wrong choice.

Collapse
 
caiangums profile image
Ilê Caian

I would never say: Redux is the wrong choice always. Sometimes you need what it offers! Sometimes, Redux is really a big DON'T.

I'm happy that you found a perfect tool for your projects!

Thread Thread
 
michaelbushe profile image
michaelbushe

Redux is never the best choice. :)