Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react array if id is present do not add element

  addPerson = (person) => {
    let filteredPerson = this.state.likes.filter(like => like.name !== person.name);
    this.setState({
      likes: [...filteredPerson, person]
    })        
  }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #react #array #id #present #add #element
ADD COMMENT
Topic
Name
7+6 =