Correct modification of state arrays in React.js
I want to add an element to the end of a state
array, is this the correct way to do it?
this.state.arrayvar.push(newelement);
this.setState({ arrayvar:this.state.arrayvar });
I'm concerned that modifying the array in-place with push
might cause trouble - is it safe?
The alternative of making a copy of the array, and setState
ing that seems wasteful.