This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-28
Channels
- # announcements (2)
- # beginners (19)
- # calva (8)
- # cider (5)
- # cljsrn (13)
- # clojure (35)
- # clojure-conj (3)
- # clojure-spain (1)
- # clojure-uk (2)
- # clojurescript (4)
- # clojutre (4)
- # cursive (13)
- # data-science (2)
- # datascript (1)
- # datomic (5)
- # duct (4)
- # fulcro (76)
- # funcool (5)
- # jobs (5)
- # off-topic (10)
- # remote-jobs (7)
- # rewrite-clj (8)
- # spacemacs (3)
- # sql (2)
- # xtdb (25)
When I run (js/require "
in repl terminal I see next error:
repl/invoke error, [ReferenceError: Can't find variable: require]
- node_modules\react-native\Libraries\YellowBox\YellowBox.js:59:8 in error
Can you explain why it's happening and how ti fix it?require
is a compile-time construct in react-native. it is not a function you can call at runtime, so it cannot be used from the REPL
just don't do it at the REPL. it works in regularly compiled files that react-native metro has processed
Aha so lets say a user will paste url to my app, and I create next function:
(defn download [url] (js/require url))
Will it work?or whatever react-native has for network requests. I don't develop react-native apps so I'm not actually sure
Another thing which I don't understand is why do I have error when I try to load audio from a URL. I use expo-va
and my code is pretty simple:
(ns example.views.notification
(:require
["expo" :as ex]
["react-native" :as rn]
["expo-file-system" :as fs]
["expo-asset" :refer (Asset)]
["expo-av" :refer (Audio)]))
(defn test []
(.catch (.then (.createAsync (.-Sound Audio) {:uri ""})(fn [x] (prn "Loaded"))) #(prn % " error")))
When I call (test) I recieve error:
#object[Error Error: Cannot load an AV asset from a null playback source] " error"
I have same code in expo snack
and it does work 😕 Please help me 🙏Couod it be because the map with uri in need to be a js object
#js {:uri "..."}
@danieleneal yeah I was thinking about same issue, I'll try to use #js {:uri "..."} tomorrow, thank you