Ajouter un nouveau tableau à l'arrière de React State
this.setState(prevState => ({
myArray: [...prevState.myArray, "new value"]
}))
Worrisome Weevil
this.setState(prevState => ({
myArray: [...prevState.myArray, "new value"]
}))
this.setState({ myArray: [...this.state.myArray, 'new value'] }) //simple value
this.setState({ myArray: [...this.state.myArray, ...[1,2,3] ] }) //another array
this.setState(prevState => ({
myArray: [...prevState.myArray, {"name": "object"}]
}))