Answers for "add new array at the back of react state"

2

add new array at the back of react state

this.setState(prevState => ({
  myArray: [...prevState.myArray, "new value"]
}))
Posted by: Guest on December-22-2020
1

add new array at the back of react state

this.setState(prevState => ({
  myArray: ["new value", ...prevState.myArray]
}))
Posted by: Guest on December-22-2020
0

add new array at the back of react state

this.setState(prevState => ({
  myArray: [...prevState.myArray, {"name": "object"}]
}))
Posted by: Guest on December-22-2020
0

add new array at the back of react state

this.setState(prevState => ({
  myArray: [ {"name": "object"}, ...prevState.myArray]
}))
Posted by: Guest on December-22-2020

Code answers related to "add new array at the back of react state"

Code answers related to "Javascript"

Browse Popular Code Answers by Language