Where to dispatch multiple actions in redux?

前端 未结 7 1583
终归单人心
终归单人心 2021-01-31 08:10

I am using redux with connect and redux-thunk middleware and containers.

Currently when an user perform an action, example one click on a butto

7条回答
  •  被撕碎了的回忆
    2021-01-31 08:48

    As other pointed out The action creator is the right place for dispatching multiple actions.

    Below an example of how action1 could dispatch other actions in your action creator.

    const action1 = id => {
      return dispatch => {
        dispatch(action2(id))
        dispatch(action3(id))
      }
    }
    

提交回复
热议问题