DEV Community


Why thunk,sagas and so many middlewares for Redux?

Ola' John Ajiboye
Software Engineer. Make stuffs with code. From the land of Promise().
・1 min read

Why do we have to use thunk sagas etc to hanlde async state chnages in React. Was it an after tought to Redux. VueX seems to handles these things well without additional middlewares.

Discussion (3)

vonheikemen profile image
Heiker • Edited

That's because Redux has a very simple implementation, and it is actually unaware of React, you have to bring react-redux for them to work together. Middlewares are necessary to add features that Redux doesn't have out the box. Actions in Redux are merely a convention, it is the recomended way of doing thing but are not necesary, the same goes for the switch statement in a reducer.

Vuex on the other hand is more complex in its implementation and it was made specifically to work with Vue. Actions are an integral part of Vuex and already provide you with features that you could find in redux-thunk.

mongopark profile image
Ola' John Ajiboye Author

True. That kind of makes sense. I forgot that Redux isn't intended just for React. Do you think context API helps in this case since it's React specific.


vonheikemen profile image

Yes, it does help. React has added features in the core library that now help with state management and side effects. If you want to know more this article is a good start: Application State Management with React.