this.state = {
listObjects : [ {Object} , {Object} , {Object} ]
}
this.setState.listObjects[1]({ })
Cannot read property '1' of undefined
console.log(this.state.listObjects[1])
this.setState((prevState) => {
prevState.listObjects[0].param = '3'
return prevState;
})
this.setState((prevState) => {
const prevArr = prevState.listObjects.slice();
let el = prevArr.shift();
el = { ...el, prop: 'value' }
return ({ listObjects: [el, ...prevArr] });
})
const changeListObjValue = (index, newValue) => {
this.setState((prevState) => {
const newArr = prevState.listObjects.slice();
newArr.splice(index, 1, newValue)
return ({ listObjects: newArr });
})
}