[Vue warn]: Duplicate keys detected: x. This may cause an update error. How to prevent adding item which has already been added via method

I have a v-autocomplete that loops a list of users. I then add them to a new list via a btn. How to I stop and alert that a user has already been added by comparing the dup key?

<v-autocomplete
    v-model="event.user"
    :items="usersData"
    label="Seach speaker list"
    :search-input.sync="searchUser"
    return-object
    item-value="id"
    item-text="name"
></v-autocomplete>

My method to addSpeaker is:

addSpeaker() {
    const newSpeaker = {
        id: this.event.user.uid,
        name: this.event.user.name,
    }
    this.speakers.push(newSpeaker)
    this.event.user = ''
},
removeSpeaker(id) {
    this.speakers = this.speakers.filter(speaker => speaker.id !== id)
}

Is there a check I can do here to prevent a user being added if it already has been?

35 thoughts on “[Vue warn]: Duplicate keys detected: x. This may cause an update error. How to prevent adding item which has already been added via method”

  1. We would like to thank you again for the lovely ideas you offered Janet when preparing her post-graduate research and also, most importantly, pertaining to providing all the ideas in a blog post. If we had been aware of your web-site a year ago, we would have been rescued from the unwanted measures we were selecting. Thank you very much.

    Reply
  2. We wish to thank you yet again for the wonderful ideas you gave Jeremy when preparing her post-graduate research plus, most importantly, for providing all of the ideas in a single blog post. Provided we had known of your web site a year ago, we will have been saved the pointless measures we were selecting. Thanks to you.

    Reply
  3. It’s the best time to make some plans for the future and it’s time to be happy. I’ve read this post and if I could I want to suggest you some interesting things or suggestions. Maybe you could write next articles referring to this article. I wish to read more things about it!

    Reply
  4. We wish to thank you yet again for the beautiful ideas you gave Janet when preparing her post-graduate research in addition to, most importantly, for providing many of the ideas in a single blog post. Provided that we had known of your web-site a year ago, we may have been rescued from the nonessential measures we were employing. Thanks to you.

    Reply
  5. I’m not sure where you’re getting your information, but great topic. I needs to spend some time learning more or understanding more. Thanks for fantastic info I was looking for this info for my mission.

    Reply
  6. Hi there! Do you know if they make any plugins to help with SEO? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good results. If you know of any please share. Appreciate it!

    Reply
  7. I am not sure where you’re getting your info, but good topic. I needs to spend some time learning more or understanding more. Thanks for magnificent info I was looking for this info for my mission.

    Reply
  8. We wish to thank you once again for the beautiful ideas you offered Janet when preparing a post-graduate research and, most importantly, for providing the many ideas in a blog post. Provided we had known of your site a year ago, we will have been rescued from the needless measures we were selecting. Thanks to you.

    Reply
  9. I am not sure where you’re getting your info, but good topic. I needs to spend some time learning much more or understanding more. Thanks for fantastic information I was looking for this info for my mission.

    Reply
  10. Does your site have a contact page? I’m having problems locating it but, I’d like to shoot you an email. I’ve got some creative ideas for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it expand over time.

    Reply
  11. Hello! Do you know if they make any plugins to help with Search Engine Optimization? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good results. If you know of any please share. Thank you!

    Reply
  12. We wish to thank you again for the gorgeous ideas you gave Jesse when preparing a post-graduate research as well as, most importantly, with regard to providing the many ideas in a blog post. Provided we had been aware of your web site a year ago, we will have been rescued from the pointless measures we were employing. Thank you very much.

    Reply

Leave a Comment