I'm amazed how much better RN dev has come in the last two years.
Prithee, what stack(s) are we all using for CLJS+RN? I am getting ready to dive back in. Glad to hear it is better! My last visit was 'bout four years ago?
It definitely has improved 🙂 My first project with CLJS + RN was back in 2016. I would say the Expo “bare” workflow is quite nice nowadays. That’s the main difference for me.
I’m using the following library like so:
https://github.com/zhangtaii/react-native-google-place-picker
(:require ["react-native-google-place-picker" :default RNGooglePlacePicker])
(defn add-address [navigation]
(.show RNGooglePlacePicker
(fn [response]
(prn "response is " response)
)))
But I’m getting the following error:
How to fix this?
basically doing (js/console.log RNGooglePlacePicker) prints null. What am I doing wrong?
try
(:require ["react-native-google-place-picker" :as lib])
(js/console.log lib)Since the documentation says do:
import RNGooglePlacePicker from 'react-native-google-place-picker';
according to the shadow-cljs user guide that would translate to :default, isn’t it?Hmm… Not sure, I am not familiar with shadow-cljs but I doubt it’s a problem from shadow per se. Things to try: • Did you link everything properly? • Always need to rebuild from xcode when adding a new library that requires native code • Clean your xcode caches, rebuild again • Restart your shadow/etc ClojureScript server processes
{"default": null}
… is suspicious, something doesn’t seem to be imported/built properly.Also, always restart yarn/npm when adding a new lib.
I am not 100% certain in the necessity of all steps, but I struggled for a few weeks initially with RN to get everything working around libs, so I do all of the above without questioning it much when adding a new lib.
@raspasov the documentation says react-native link for automatic link
Do I have to do a manual link?
Usually not.
If you’re on a recent React Native version.
that’s right I am on a recent version
react-native: 0.63.4
That should be ok then, if it reports all linked properly when you added the lib initially.
yes I rebuilt from xcode
Have you tried without the “” react-native-google-place-picker ?
I believe “” are only needed if the lib starts with @
yes I tried without the apostrophes but still getting null
how to clean xcode cache?
I clean it using Menu Bar -> Product -> Clean Build Folder
I also restarted shadow-cljs server process
@ps please read the doc section specifically about the default exports. https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports
you do have the correct translation using :default
but unfortunately that doesn't automatically mean that it is correct. so definitely try :as
as well
beyond that shadow-cljs does not process any dependencies for RN projects. so maybe you need to restart the metro
stuff and reset its indexes