In React, I want to set an inner property of an object stored in a state.
Suppose the following:
const myIndex = 0;
const [myobject, setmyobject] = useState({
a: {
b: [
{c: 1},
{c: 2}
]
}
})
I want to modify myobject, replacing c with 3 in the first object of the b array.
So I want to do this:
setmyobject({...myobject, a.b[myIndex].c: 3});
But it gives me an error, : or , expected in the first [.
Is this forbidden?
