此操作引发以下错误:
setTimerState(state, { payload }: PayloadAction<{ timer: StepTimer, timerState: CookingTimerState }>) {
const { timer, timerState } = payload
const timerInStore = state.stepTimers
.find(t => t.timerId === timer.timerId)!
timerInStore.state = timerState
}
错误:不变量失败:在调度内检测到状态突变,路径为:cookingSession.stepTimers.0.state。看一下处理动作 {"type":"session/setTimerState","payload":{"timer":{"label":"Dance","durationSec":600,"stepIndex" 的 reducer :0,"timerId":0,"state":2},"timerState":2}}
我认为 Redux 工具包允许您进行这种状态更改。是因为我StepTimer
的 s 是类对象而不是 POJO 吗?