【发布时间】:2020-12-10 20:58:16
【问题描述】:
我已经使用 createSlice 创建了一个动作和减速器。
在其中一个操作中,我使用来自状态的集合来调用服务。我想根据服务的响应更新状态数据。
成功时我想更新state.locations,失败时我想更新state.errorData。
const ManageInventoriesState = createSlice({
name: "ManageInventoriesReducer",
initialState,
reducers: {
updateIventoryLocations: (state) => {
updateService(state.oprationsList).then((resp) => {
state.locations = resp.data;
}).catch((err) => {
state.errorData = err.data;
});
},
},
});
但是当我尝试这样做时,我收到以下错误,
无法对已撤销的代理执行“设置”。
如何正确做。
我只是从 UI 发送操作(UI 是 connected component)。
dispatch(updateIventoryLocations());
【问题讨论】:
标签: reactjs typescript redux redux-thunk immer.js