find and update state react code example
Example 1: update object in array state by index
this.setState(({items}) => ({
items: [
...items.slice(0,1),
{
...items[1],
name: 'newName',
},
...items.slice(2)
]
}));
Example 2: reactjs update state example
{
hasBeenClicked: false,
currentTheme: 'blue',
}