react array if id is present do not add element

Solutions on MaxInterview for react array if id is present do not add element by the best coders in the world

showing results for - "react array if id is present do not add element"
Kia
11 Oct 2020
1  addPerson = (person) => {
2    let filteredPerson = this.state.likes.filter(like => like.name !== person.name);
3    this.setState({
4      likes: [...filteredPerson, person]
5    })        
6  }