I have done a lot of research and I saw a lot of similar questions but non answer this.
I am trying to update a nested array, I have tried a lot of different variations but non work.
onChange={(e) => setUser([{ ...User[index], permissions : {CreateSubs : e.target.value} }])}
Right now this of course erases the other items I have inside of permissions arr, how do I just update the specific one I need?
[
{
User: {
name: "Name",
permissions: {
CreateSubs: true,
CreateOtherStuff: false,
},
},
},
]
Update
All the other article i found are not using react hooks, and it's a bit different
Below is what worked for me
onChange={(e) => setUser([ { ...User[index], permissions: { ...User[index].permissions, CreateSubs: e.target.checked } } ])}