Learn JavaScript – Online Resources




React Redux Vs Context API


I am not sure of the many points that covers in different articles explaining Redux Vs Context API.

Context API: https://reactjs.org/docs/context.html

In my experience, the difference i found is,

Context API cannot change the states and its only meant to carry

Also, if you are using router in your project where you carry the context in parent and used child as a router, in that case context will not work.


App->xyz(parent) -> abc(child)

If you use provider in parent and access abc using router(localhost:3000/abc) without App/xyz, then you are not carrying your context and it will not work in that way. In this case, you have to use Redux alone.

In simple words,

redux is like a ‘var’ keyword, where you can use/access and also update the value in that variable. ( I mean you can access state and also update the state)

context API is like a ‘const’ keyword, you can only use/access it and cannot update it.