Answers for "how to use state array and add array in setsate in react js"

4

add array of object to state react

setTheArray(currentArray => [...currentArray, newElement])
Posted by: Guest on November-07-2020
6

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

Code answers related to "how to use state array and add array in setsate in react js"

Browse Popular Code Answers by Language