1
const InitialState = {
  uploadImages: [],
};

On the first update it gets filled with objects and looks like that:

const InitialState = {
  uploadImages: ['a', 'b', 'c', 'd'],
};

i get payload:

{arrayIndexToChange: 1, ValutAtIndex: 'e'}

Is there anyway i can return immutable state inside my reducer like:

return [...state, //someway to update value at index in array ]
rosnk
  • 1,068
  • 1
  • 14
  • 36
  • also see:https://redux.js.org/recipes/structuring-reducers/immutable-update-patterns#updating-an-item-in-an-array - `return state.map((x, i) => i === action.payload.arrayIndexToChange ? action.payload.ValueAtIndex : x);` – Nick Parsons Mar 13 '21 at 05:23

0 Answers0