3
have the following object:
obj = {
title: "obj1",
tab: [{
title: "titulo da tab 1",
card: [{
title: "card1",
url: "url",
image: "image"
},
{
title: "card2",
url: "url",
image: "image"
}]
},
{
title: "titulo da tab 2",
card: [{
title: "card3",
url: "url",
image: "image"
},
{
title: "card4",
url: "url",
image: "image"
}]
}
]
}
when I want to change the status of a variable in the use React
setState({obj1: data})
when I want to change the status of an obj property I use:
setState({obj1: {...this.state.obj1, title: "new title"} })
but my difficulty is:
- How to change the title of a card in obj?
- How to change a tab title in obj?
is this.state same or is this.state.obj1 ? on line 1
– Julio Henrique
@Juliohenrique It was my mistake, I didn’t notice that the state has as its root object the
obj1
, but the idea is to capture the whole state which is easier. I will adjust– Isac