Sandbox: https://codesandbox.io/s/ucjrx?file=/src/features/todos/todosSlice.js
In todoSlice.js, at line 14, when I try to do console.log, it is printed as a revoked proxy (browser console). But when I put a breakpoint in chrome dev tools and go through that line step by step, it is not a revoked proxy. Why is this happening?
In a RTK reducer, your state is wrapped in a Proxy object by the immer library to detect modifications. After the reducer is finished, that proxy object is revoked to prevent memory leaks.
Unfortunately,
console.logdoes not log a in-time snapshot of an object, but a reference - and the time you try to actually explore these contents, it's already revoked.As the documentation explains, you should log draft state values using the
currentexport from immer that is re-exported from RTK: