I have a redux reducer as follows:
function x(state = null, action){
switch(action){
case 'FILTER_DATA': {
let { data } = state;
let newData = someOperation(data);
let s1 = deepCopy(newData);
let s2 = s1.filter((v,i) => i%2);
return {
...state,
v1: s1,
v2: s2
};
}
}
}
If s1 is an array of nested objects - then some deep reference inside s2 will also point to the same object in memory.
Is it okay for a reducer to return a modified state - where 2 keys are almost pointing to the same object? Does it make the reducer impure and the overall code to function incorrectly??