Redux & Redux Toolkit
/Intermediate
Draft State
Definition
The term used by Immer to describe the Proxy object you interact with inside an RTK reducer. It represents the 'in-progress' changes before they become the final immutable state.
Explain Like I'm New
A temporary scratchpad. Inside `createSlice`, the `state` variable passed into your reducer is not the REAL state. It is a 'Draft'. You can scribble all over the draft, and when the function ends, Immer prints a final, clean copy based on your scribbles.
Real World Example
Modifying `state.user.name = 'Bob'` inside a slice reducer.
Common Use Cases
- •Understanding RTK reducer mechanics
Interactive Example
Loading Code Playground...
Interview Questions
basic
- Can you `console.log(state)` directly inside an RTK reducer to see your data?
intermediate
- How do you properly log the Draft State in RTK so you can read it?