I'm currently try to update the state object inside of my react class based component.
The problem is that my state is an 2 dimensional array which looks like this:
this.state = {
items: [
{
title: 'first depth',
items: [
{
title: 'second depth',
},
],
},
],
};
For updating the first depth of the array inside my state object I use this code:
this.setState(({items}) => ({
items: [
...items.slice(0, index),
{
...items[index],
title: 'new Title',
},
...items.slice(index + 1),
],
}));
But I cannot update the second depth of the array inside my state.
Does someone has an idea how to update the second depth?