I am trying to change one item in of an array in my state using a reducer.
State looks like:
state: {
  items: [
  {
    id: 1,
    name: 'Superman',
    wearsCape: true
  },
  {
    id: 2,
    name: 'Batman',
    wearsCape: true
  },
  {
    id: 3,
    name: 'Iron Man',
    wearsCape: false
  }
];
}
I am trying to filter through all the items in the state to search for first occurance of a superhero that has name equal sHero.name. Then I am trying to change a property of found superhero. The reducer code looks like:
function findCapedCrusader(state, { sHero }) {
  var result = state.items.filter(s => {
    return s.name === sHero.name;
  });
  result[0].wearsCape = false;
  return { ...state };
}
Am I mutating the state by doing the above??
NOTE: apologies for stupid example. I am new to react and redux.