Fork me on GitHub
#cljsrn
<
2019-06-26
>
jgood00:06:56

:man-raising-hand: @thheller I'm probably doing something stupid but I can't seem to import this expo module. https://docs.expo.io/versions/latest/sdk/filesystem/. I think I'm doing it correctly according to shadow-cljs import directions. https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages.clojure But it doesn't seem to work.

(ns time-align-mobile.handlers
  (:require
    ["expo-file-system" :as FileSystem :refer [documentDirectory]]

...
;; Then after loading the namespace into the repl

cljs.user> (ns time-align-mobile.handlers)
time-align-mobile.handlers
time-align-mobile.handlers> (identity FileSystem)
nil

time-align-mobile.handlers> documentDirectory
;; output cleared

time-align-mobile.handlers> (.-documentDirectory FileSystem)
;; output cleared

time-align-mobile.handlers> FileSystem/documentDirectory
;; output cleared

time-align-mobile.handlers> (.documentDirectory FileSystem)
;; output cleared

...
;; all result in an error like this

repl/invoke error, [TypeError: undefined is not an object (evaluating 'shadow.js.shim.module$expo_file_system.documentDirectory')]

joshmiller01:06:11

@jgoodhcg I think your issue might just be doing (ns ...) instead of (in-ns ...) from the REPL

thanks2 4
joshmiller01:06:54

(it also might not, but if it’s actually shadow-cljs, I won’t know the answer)

mfikes02:06:17

Yeah, doing ns clears out any aliases you might have set up. More exposition on that here https://stackoverflow.com/a/35713553/4284484

thanks2 4
thheller08:06:26

@jgoodhcg all the requires in react-native are filled in by metro which means they can't be done dynamically at the REPL. It only works when the namespace is loaded regularly and then switched to via in-ns

thanks2 4