You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@SilvaQ and @jefflombard - I don't mean to revive an old thread, but I was interested in the project and looked at the code above. What if you installed lodash.clonedeep (this one may be outdated) or standard lodash via npm or yarn and then used that. For example:
This at the top of the file in either one of these commands:
import{cloneDeep}from'lodash';
OR
importcloneDeepfrom'lodash/cloneDeep';
Then:
(state,action)=>{constpreState=cloneDeep(state);// deep copy first before consumeconstnext=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;");// 上一个stateconsole.log("%cPrevious State:","color: #9E9E9E; font-weight: 700;",preState);
If this is something that can be done at the core of the project, you can always cherry pick lodash functions without bringing in the entire suite. :-)
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:
The text was updated successfully, but these errors were encountered: