React Redux Vs Context API

Folks,

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.

Say,

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s