When using console.log()
inside a reducer action, the state prints as a Proxy object, instead of the object I actually want to see. How do I see the actual object? I am using redux-starter-kit createSlice, I am not sure if this has anything to do with it.
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;
This is the output I see in the console when I toggle my ToDo: