DEV Community

Discussion on: Redux vs Context (why and where)

Collapse
 
markerikson profile image
Mark Erikson • Edited

Hi, I'm a Redux maintainer. The answer is not as simple as "Redux for complex apps, Context for simple apps". It's important to understand that Redux and Context are different tools that solve different problems.

I recently wrote a post called Why React Context is Not a "State Management" Tool (and Why It Doesn't Replace Redux), which is intended to be a definitive explanation for what the purposes and use cases are for each of these tools and when it makes sense to use them.

Collapse
 
bazen profile image
Bazen • Edited

Nice article @markerikson , it very definitive on what is what. I have used redux in many projects & I quite like it. however one of the things that bugs me often is when I'm working on big project & there comes a scenario in which I want to store state with short life time and is only consumed by few components (eg. form with multiple steps) in such case it did not make that much sense to me to store this state in global state manager but at the same time I didn't want to store it in local state to avoid prop-drilling. for me this is where context usually comes in & taking the best of both makes things much easier. what I want to point out is there is a scenario in which Context fills Redux's shortcoming & vice versa hence in my opinion seeing the as one versus the other might not be valid point.

Collapse
 
m0rfes profile image
M0rfes • Edited

With all due respect. I think I failed to get my point across in the why context and where context section. I know it's just a DI solution but since I planned this article for new developers I tried to not use such technical terms as dependency injection and such. Since most totorials teach context with useState and useReducer as state management solution I went with it

Collapse
 
mukhammadsobirov profile image
Mukhammad Sobirov

The reason why I choose to go with redux, when it comes to state management is because of it's maintainers. They're soo active and conscientious, that there's a solution to any potential issues that might come up.

Thank you guys!