【发布时间】:2018-11-23 10:13:53
【问题描述】:
我们可以在 action creators 中使用 dispatch 吗?它们在 action creators 中服务的目的是什么? 这是来自代码库的示例修改代码。
export default function xyz(data) {
const url = ;
return function (dispatch) {
dispatch(
a()
);
callApi(url, REQUESTS.POST, HEADERS, data).then((response) =>{
dispatch(
b(data)
);
}).catch((error) => {
dispatch(
c(error.toString())
);
});
};
}
// this returns a type (an object)
export function a() {
return {
type: xyzzzz
};
}
Similarly we have b and c returning either type or say objects .
【问题讨论】:
标签: redux react-redux