How to use the react-native-contacts.deleteContact function in react-native-contacts

To help you get started, we’ve selected a few react-native-contacts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rt2zz / react-native-contacts / example / src / index.js View on Github external
Contacts.getAll((err, contacts) => {
      let contactToDelete = _.find(
        contacts,
        (contact) => contact.givenName
          && contact.givenName.indexOf(PREFIX) === 0
      )
      if (!contactToDelete) {
        contactToDelete = contacts[0]
      }
      console.log('attempting to delete', contactToDelete)
      Contacts.deleteContact(contactToDelete, (err, data) => {
        Contacts.getAll((err, newContactList) => {
          console.log('resultant list', newContactList)
          invariant(
            newContactList.length === contacts.length -1,
            'getAll should return one less result'
          )
          invariant(
            !_.find(newContactList, {recordID: contactToDelete.recordID}),
            'contact should not longer exist'
          )
        })
      })
    })
  }
github rt2zz / react-native-contacts / example / App.js View on Github external
onDelete={() =>
                  Contacts.deleteContact(contact, () => {
                    this.loadContacts();
                  })
                }