我需要更改我创建的字符串中的值.但我不能编辑,因为Typescript 说我正试图进入无效状态 enter image description here个
创建字符串和子字符串后,它们都显示在ReduxDevTools中 enter image description here个
但是,如果您向控制台输出State.Levels,它会显示原型或某些错误...不是你工作所需要的 enter image description here个
我需要更改我创建的字符串中的值.但我不能编辑,因为Typescript 说我正试图进入无效状态 enter image description here个
创建字符串和子字符串后,它们都显示在ReduxDevTools中 enter image description here个
但是,如果您向控制台输出State.Levels,它会显示原型或某些错误...不是你工作所需要的 enter image description here个
因为Redux工具包的createReducer
API在内部自动使用immerjs,所以Reducer中的状态是Draft状态,它是当前状态的代理.见Debugging and Inspecting Drafted State
RTK转口
current
个.如果您需要记录或判断正在进行的工作状态,则可以在减速机中使用此功能.
import { current } from '@reduxjs/toolkit'
const todosSlice = createSlice({
name: 'todos',
initialState: todosAdapter.getInitialState(),
reducers: {
todoToggled(state, action) {
// ❌ ERROR: logs the Proxy-wrapped data
console.log(state)
// ✅ CORRECT: logs a plain JS copy of the current data
console.log(current(state))
},
},
})