I'm looking for a way to update a single index of an object's values that are an array while saving the state of the other values. I tried using a spread operator, but I'm getting an error.
const [points, setPoints] = useState({"x": [46, 168, 292, 415, 537, 660] , "y":[60, 192, 324, 454]});
const update = (e) => {
setPoints(points => ({
...points,
x[0]: e
}));
};
I am unsure how to update the specific index.
Thanks!