I have the following state update function for a redux array
if (replace) {
return {
...state,
mySelectionOtrosFiltros: items
}
} else {
return {
...state,
mySelectionOtrosFiltros: state.mySelectionOtrosFiltros.concat(a[0])
}
}
If replace is false, the state update works properly, and I can see it being updated.
But if repace is true, i want to substitute mySelectionOtrosFiltros which is an array of objects, completly by a new array of objects named items
But that case isnt working.
I can see state.mySelectionOtrosFiltros being updated, but its not rerendered so i guess im messing up the inmutability. It will only be rendered properly if i trigger the else statement , in that case the new element is added and the previous updates are now displayed.
example of non working case
mySelectionOtrosFiltros = [{a: 1 , b: 2, c: 3}]
items = [{a: 2, b: 2, c: 2},{a:4 , b: 4, c: 4}]
myselectionotrosfiltros should be replaced with items completly, so it looks like items
return {
...state,
mySelectionOtrosFiltros: items
}
it doesnt get replaced
items