在console.log()
reducer 操作中使用时,状态打印为 Proxy 对象,而不是我真正想看到的对象。我如何看到实际的对象?我正在使用 redux-starter-kit createSlice,我不确定这是否与它有关。
import { createSlice } from "redux-starter-kit";
export interface IToDo {
id: number;
name: string;
complete: boolean;
}
const initialState: IToDo[] = [
{
id: 1,
name: 'Read a bit',
complete: true
}
];
const { actions, reducer } = createSlice({
slice: "todos",
initialState,
reducers: {
toggleTodo(state: IToDo[], action) {
const todo = state.find(todo => todo.id === action.payload);
console.log(todo);
if (todo) {
todo.complete = !todo.complete;
}
}
}
})
export const toDosReducer = reducer;
export const { toggleTodo } = actions;
这是我在切换 ToDo 时在控制台中看到的输出: