DEV Community

Using React - Context vs Redux

Williams Oluwafemi on December 16, 2019

Working with React, at some point would make you think there has to be a better way to manage your states across your application - well yes, Redux...
Collapse
 
rricardocoder profile image
Ricardo el coder

I prefer context instead of redux. Even more when you use context with React hooks, it turns so much easier.

Collapse
 
vvilliam5 profile image
Williams Oluwafemi

Sure might be a breeze if you use them with Hooks, but what about people with a preference for class based components

Collapse
 
dance2die profile image
Sung M. Kim

One thing to note is that, when any data in context changes, any components using the context would be re-rendered.

For Redux, only the components that connects to the changed data is re-rendered.

Collapse
 
vvilliam5 profile image
Williams Oluwafemi

Exactly 10 points for Redux 😁

Collapse
 
bardaxx profile image
Giacomo Alonzi

Yes by if you connect a view to the store, when the store change and the entire view is rerendered is not the same as context?

Thread Thread
 
dance2die profile image
Sung M. Kim

Redux used to used Context for v6, they removed it in v7+ as that was the issue.

Thread Thread
 
bardaxx profile image
Giacomo Alonzi

what u mean?

Collapse
 
bardaxx profile image
Giacomo Alonzi

Context + useReducer is for me the best way for state management.

 
vvilliam5 profile image
Williams Oluwafemi

Lol who are the 'official dev team'?