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

前端 未结 3 1762
执笔经年
执笔经年 2020-12-04 06:18

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 red

3条回答
  •  無奈伤痛
    2020-12-04 06:27

    Full disclosure: I'm relatively new to Redux development and struggled with this question myself. I'll paraphrase the most succinct answer I found:

    ReduxPromise returns a promise as the payload when an action is dispatched, and then the ReduxPromise middleware works to resolve that promise and pass the result to the reducer.

    ReduxThunk, on the other hand, forces the action creator to hold off on actually dispatching the action object to the reducers until dispatch is called.

    Here's a link to the tutorial where I found this info: https://blog.tighten.co/react-101-part-4-firebase.

提交回复
热议问题