React add array to state

Code Examples, React Native, ReactJS

React add array to state

this.setState({ user_ids: [...this.state.user_ids, 25] });
this.setState({ user_ids: [...this.state.user_ids, ...[1,2,3] ] });

this.setState(prevState => ({
  user_ids: [...prevState.user_ids, users]
}));

click for more React codes, read about react doc