DEV Community

Discussion on: How to manage global data with Context API, without Redux on React

Collapse
 
leob profile image
leob • Edited

By now I've seen many articles saying "you don't need Redux, use Context (with useReducer and so on). Prove me that it's simpler with Context than with Redux, and that you need way less boilerplate - because I genuinely don't see it!

It's (a bit) different but not necessarily better, the only objective advantage is you need one or two fewer dependencies in your package.json. Conceptually it's almost the same and much of the code is also largely the same, only a few pieces of syntax differ.

Collapse
 
taishi profile image
Taishi

Prove me that it's simpler with Context than with Redux

I have never said it's simpler than Redux, but 1. Use state variable can be an easier and better way for a small app to manage data globally.

the only objective advantage is you need one or two fewer dependencies in your package.json

This is a big merit for me to use Context API instead of Redux.

much of the code is also largely the same

That's why you can replace Redux with Context API with ease.

Thanks.

Collapse
 
faiwer profile image
Stepan Zubashev

That's why you can replace Redux with Context API with ease

If you want to replace Redux with your own solution using context API (btw redux uses it too under the hood), you need to implement much more code than you did in this article. Otherwise your solution would be extremely slow at big projects.

Thread Thread
 
leob profile image
leob • Edited

That's also what I fear, having read about that in other articles - you can get unnecessary re-renders and so on unless you implement further optimizations - by then you'd start wondering if you threw out the baby with the bath water.