0

Why is Contacts null in React Native CLI when using react-native-contacts@8?

I'm building a mobile app using React Native CLI (not Expo), and I'm trying to use the react-native-contacts library (version 8.0.4). I've followed all the instructions for Android (added permissions, requested them at runtime), but calling:

Contacts.getAll()

throws this error:

TypeError: Cannot read property 'getAll' of null

When I inspected the source code in node_modules/react-native-contacts/index.ts, I noticed that the module resolution depends on this line:

const isTurboModuleEnabled = global.__turboModuleProxy != null;

In my case, global.__turboModuleProxy is defined, but TurboModuleRegistry.get('Contacts') returns null, so the whole module is null.

As a workaround, I imported directly from:

import Contacts from 'react-native-contacts/src/NativeContacts';

And it works, but I know this isn't safe or recommended for production.


My setup:

  • React Native CLI (0.79.1)
  • [email protected]
  • Android device
  • Permissions granted via PermissionsAndroid
  • Metro reset & gradlew clean done
  • Contacts still resolves to null

My question:

  • Why is Contacts resolving to null even though TurboModule seems enabled?
  • Should I downgrade to [email protected] to avoid this?
  • What’s the correct and stable way to use react-native-contacts in a non-TurboModule setup?

Any help would be appreciated 🤝

New contributor
Abduvali Nazirov is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.