How to dispatch an action, in dva with .then (() = > {})

the dva project needs to trigger an action, of Synchronize to change the query parameters on the state tree, and then get the get interface parameters in .then?

Mar.07,2021

dispatch A reducer cannot return a Promise object, so .then cannot be used.
only a dipsatch effects can return a Promise.
so if you want Synchronize, you can only write it in effects:

effects: {
    * myAyns({}, {call, put}) {
        yield put({type: 'yourReducer'});
        yield call(/*....*/);
    }
}

that's fine.

Menu