I'm trying to figure out why my components are not updating after Redux's store receives new data. Github issues seem to indicate that I'm mutating the object without returning it, but I haven't been able to find how to do this with entire arrays.
Here's my current code.
initialState = []
...
switch(action.type) {
case "SET_STORIES": {
state = [...action.payload]; // data is an array of objects.
// does not work either: state = [...state, action.payload];
break;
}
}
return state;
In the same command, I 'd also like to overwrite the entire array if there is previous data present.
Is this correct? (console logs logs the updated array, but does this mean its being returned to the components?)