r/Clojurescript • u/chowbeyputra • Jan 23 '22
Import external libraries from react-native.
Hi, I am using Krell for react-native and trying to use contacts but nothing seems to work.
The last thing I tried was (:require ["react-native-contacts" :as contacts]) for importing and (.getAll contacts) for the js counterpart :
Contacts.getAll().then(contacts => { // contacts returned })
but got this error:
[TypeError: undefined is not an object (evaluating 'xxxx.core.node$module$react_native_contacts.getAll')]
What am I missing?
2
Upvotes
View all comments
Show parent comment
1
u/dark-light92 Feb 28 '22
Ok thanks. On shadow-cljs none of them seem to work. Instead I got it working by importing the native module directly like this:
You can find the native module name by doing a search for getName method on the repo. For react-native-contacts, the name is "Contacts". (https://github.com/morenoh149/react-native-contacts/blob/5862de1bb5785277915622770f7c114b9b770319/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsManager.java)