Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

using plice to remove an element from an array in react

removePeople(e) {
  var array = [...this.state.people]; // make a separate copy of the array
  var index = array.indexOf(e.target.value)
  if (index !== -1) {
    array.splice(index, 1);
    this.setState({people: array});
  }
},
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #plice #remove #element #array #react
ADD COMMENT
Topic
Name
5+1 =