add new array at the back of react state

Solutions on MaxInterview for add new array at the back of react state by the best coders in the world

showing results for - "add new array at the back of react state"
Raphael
06 Nov 2017
1this.setState(prevState => ({
2  myArray: [...prevState.myArray, "new value"]
3}))
4
Emmanuel
31 Jun 2017
1this.setState(prevState => ({
2  myArray: ["new value", ...prevState.myArray]
3}))
4
Anna
21 Nov 2017
1this.setState(prevState => ({
2  myArray: [...prevState.myArray, {"name": "object"}]
3}))
4
Finn
04 Jan 2018
1this.setState(prevState => ({
2  myArray: [ {"name": "object"}, ...prevState.myArray]
3}))
4