Answers for "setState array"

5

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
Posted by: Guest on November-11-2020
0

setState array

setState([...arr,new])
Posted by: Guest on July-27-2021

Browse Popular Code Answers by Language