return promise from store after redux thunk dispatch

后端 未结 3 866
慢半拍i
慢半拍i 2020-12-08 01:58

I am trying to chain dispatches with redux thunk

function simple_action(){
  return {type: \"SIMPLE_ACTION\"}
}

export function async_action(){
  return fun         


        
3条回答
  •  情书的邮戳
    2020-12-08 02:30

    dispatch will return whatever the action/function it calls returns; so if you want to chain certain activities (as per your example), your action would need to return a Promise.

    As @Aaleks mentions, if your action were a thunk you can create a scenario where you return a Promise, then you could do as you mention.

    BTW I think naming your thunk action_creator is a bit misleading, as simple_action is actually an Action Creator in Redux parlance - have edited accordingly :)

提交回复
热议问题