how to pass an array in state react code example
Example 1: how to update react state array
const [myArray, setMyArray] = useState([1,2,3])
// to update
setMyArray([...myArray, 4]); // --> myArray = [1,2,3,4]
Example 2: how to add array data on state react
this.setState({ myArray: [...this.state.myArray, 'new value'] }) //simple value
this.setState({ myArray: [...this.state.myArray, ...[1,2,3] ] }) //another array