Problem Statement
How does Immer work in RTK reducers and what should you be careful about?
Explanation
Immer wraps your reducer in a produce function that provides a draft state you can safely mutate, and Immer tracks all changes to produce an immutable updated state using structural sharing for efficiency. You can write either mutating logic or return new state, but never both in the same reducer case because returning a new value tells Immer to ignore the draft mutations. Be careful not to return the draft state itself, avoid mutating state from outside the produce wrapper, and remember that async code or callbacks might not work as expected since they execute outside Immer's tracking context.
