DEV Community

JARVUC
JARVUC

Posted on

Should we ditch Redux for Context Hook?

Is context gonna end Redux's career?

With the React Hooks, problems are being solve! To use the hooks, we need to develop our app using functional components. We don't need to install additional package just to handle global states.

Example of functional component

function app(){
 return ()
}

Enter fullscreen mode Exit fullscreen mode

But is the Context hook enough to bury the Redux for good in the near future?

  • What would be the advantage of Redux and Context?

It would be awesome if we could discuss it here. Opinions are welcome!

Top comments (9)

Collapse
 
jh3y profile image
Jhey Tompkins

This is an interesting topic 👍 I think as times goes by we see an evolution in the tools available for the Context API. The point about debugging features for redux is a big one, and packages like redux-persist are also convenient. However, with a little elbow grease, we can attain these benefits for use with the Context API I'm lead to believe. For example, we can write our own custom localStorage based persistence for Context. And there are tools out there to help with debugging if the React DevTools are not enough. react-waterfall seems to be an option for using redux-devtools with the Context API 👍

Collapse
 
kojiadrianojr profile image
JARVUC

Thank you for having interest in the topic.

The tools we use are improving and making it easier for the developers in creating their app. There are developers that is already refactoring from class component to function component, maybe because of the hooks?

Given that hooks are still young, they have a lot room for improvement and may take inspiration from older tools.

Collapse
 
jh3y profile image
Jhey Tompkins

It's definitely an interesting space 👍

Collapse
 
fly profile image
joon

Nope, I believe that redux debugging features are already too well made and have already (sort of) taken control of the market.
Kind of like how most devs agree that svelte is a more efficient framework, yet still use react - it already has a powerful stance along with an ecosystem supporting it.

Collapse
 
kojiadrianojr profile image
JARVUC

Yes, debugging in Redux is indeed too well made.

Collapse
 
psyduck profile image
psyduck

useReducer + useContext = redux , right ?

Collapse
 
dance2die profile image
Sung M. Kim • Edited

No.

Redux has a nice middlware, with which you can provide async or other (such as logging) functionalities.

And also all components using the context re-renders if the context changes, while Redux causes re-render only for components that subscribed to the changed data.

Redux also has a wide range of community (as it's not just for React) and the documentation is excellent, not to mention a good tooling support.

Collapse
 
kojiadrianojr profile image
JARVUC

Context Hook and Reducer are good for developing apps that are not too small, and also not too complex. I love using Redux when the project is way too big.

Collapse
 
kojiadrianojr profile image
JARVUC

maybe it's like Redux but not totally.