Removing element from array in component state

The Solution to Removing element from array in component state is


The cleanest way to do this that I've seen is with filter:

removeItem(index) {
  this.setState({
    data: this.state.data.filter((_, i) => i !== index)
  });
}

~ Answered on 2015-08-05 17:10:01


Most Viewed Questions: