RaHuL - House Javascript RaHuL - House Javascript - 1 year ago 142
React JSX Question

What is the difference between redux-thunk and redux-promise?

As far as I know and correct me if I am wrong, redux-thunk is a middleware which helps us dispatch async function and debug values in the action itself while when I used redux-promise I couldn't create async functions without implementing my own mechanism as Action throws an exception of dispatching only plain objects.

What is the major differences between these two packages? Are there any benefits of using both the packages in a single page react app or sticking to redux-thunk would be enough?

Answer Source

redux-thunk allows your action creators to return a function :

function myAction(payload){
    return function(dispatch){
        // use dispatch as you please

redux-promise allows them to return a promise :

function myAction(payload){
    return new Promise(function(resolve, reject){
        resolve(someData); // redux-thunk will dispatch someData

Both libraries are useful if you need to dispatch action async or conditionally. redux-thunk also allows you to dispatch several times within one action creator. Whether you choose one, the other or both entirely depends on your needs/style.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download