morenoh149 / react-native-contacts

React Native Contacts
MIT License
1.64k stars 560 forks source link

null is not an object (evaluating t.givenName[0]) #610

Closed zina-vilmate closed 3 years ago

zina-vilmate commented 3 years ago

I have an issue with some android devices such as Redmi Note 8T and Redmi Xiaomi 9T Pro when I'm calling Contacts.getAll() it's always resolving into error null is not an object (evaluating t.givenName[0]). I'm sure that the user gave the permissions and that all the contacts have givenName. I'm stuck for now and it's critically important for my app to have access to contacts.

Any help welcome, thanks in advance.

react-native: 0.64.0 (same was with 0.63.4) react-native-contacts: ^6.0.4

morenoh149 commented 3 years ago

try wrapping the t.givenName[0] by a length check. If that works please submit a PR.

zina-vilmate commented 3 years ago

wrapping in a catch? or where?

morenoh149 commented 3 years ago

share your code

zina-vilmate commented 3 years ago

I'm asking permission in a previous component and I'm getting here only if permission is granted

 Contacts.getAll()
      .then(contacts => {
        setListOfContact(contacts);
      })
      .catch(err => {
         // and here I'm getting the error message null is not an object (evaluating t.givenName[0])
      });
morenoh149 commented 3 years ago

do you declare a variable t anywhere?

Also try running the example app https://github.com/morenoh149/react-native-contacts/blob/8ef41d4563cf382e791b8c6fa6961d55559e84b6/example

github-actions[bot] commented 3 years ago

This issue is stale, please provide more information about the status