I am trying to modify some states to have them displayed differently but I can't seem to modify it without getting an error telling me to not mutate the state. I have tried using .concat, .slice, and the spread operator to copy the state array but it doesn't seem to work.
const { cart, totalCartPrice, totalItemsInCart } = useSelector(
(state) => state
);
const cartHandler = () => {
const copyCart = cart.concat();
copyCart[0].name = "New Name"
setDisplayCart(copyCart)
};