-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Labels
help wantedExtra attention is neededExtra attention is needed
Description
if the state is object ,logger pre state will be change ,so pre and now is the same ref.
we need to deep copy befor excute the reducer.
my code:
(state, action) => {
const preState = { ...state }; // deep copy first befor consume
const next = reducer(state, action);
if (debug) {
console.group(
`%cAction【${action.type}】%cat ${getCurrentTimeFormatted()}`,
"color: lightgreen; font-weight: bold;",
"color: #9E9E9E; font-weight: 700;",
"color: lightblue; font-weight: lighter;"
);
// 上一个state
console.log(
"%cPrevious State:",
"color: #9E9E9E; font-weight: 700;",
preState
);Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is needed