【发布时间】:2021-08-21 08:57:56
【问题描述】:
我有一个 thunk 动作是由 createAsyncThunk 创建的。我想在调用 api 更新状态之前调度一个动作。
我不想使用动作getProducts.pending,因为我想调度actionLoading() 用于其他thunk 动作。
我该怎么做?谢谢!
export const getProducts = createAsyncThunk("getProducts", async () => {
// I want dispatch action actionCallAPIPending like that
// dispatch(actionLoading());
const response = await axios.get("api");
return response;
});
【问题讨论】:
标签: reactjs redux redux-toolkit