how to set state with array code example
Example: how to update array in react state
this.setState(prevState => ({
arrayvar: [...prevState.arrayvar, newelement]
}))
this.setState(prevState => ({
arrayvar: [...prevState.arrayvar, newelement]
}))