how to use push for react setstate code example
Example 1: add new array at the back of react state
this.setState(prevState => ({
myArray: [...prevState.myArray, "new value"]
}))
Example 2: usestate array push
setTheArray([...theArray, newElement]);
Example 3: add new array at the back of react state
this.setState(prevState => ({
myArray: ["new value", ...prevState.myArray]
}))