This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-06-10
Channels
- # announcements (2)
- # asami (2)
- # babashka (29)
- # beginners (115)
- # cider (5)
- # clara (9)
- # cljdoc (14)
- # cljs-dev (1)
- # cljsrn (18)
- # clojars (3)
- # clojure (73)
- # clojure-australia (7)
- # clojure-europe (74)
- # clojure-nl (3)
- # clojure-norway (8)
- # clojure-spec (3)
- # clojure-uk (36)
- # clojured (1)
- # clojurescript (15)
- # conjure (18)
- # datomic (6)
- # deps-new (11)
- # depstar (7)
- # fulcro (2)
- # instaparse (1)
- # jobs (9)
- # nrepl (8)
- # off-topic (21)
- # pathom (5)
- # polylith (42)
- # proletarian (1)
- # rdf (10)
- # re-frame (2)
- # react (1)
- # reagent (20)
- # releases (3)
- # remote-jobs (4)
- # rum (9)
- # shadow-cljs (79)
- # sql (11)
- # tools-deps (64)
- # vim (3)
- # xtdb (26)
I guess I'm doing something incorrectly here...
(rum/defc image-preload < rum/reactive []
[:div
(map #([:img {:src %}]) (vals setting-map))])
My issue is that on mobile the images for this javascript app do not load, so I thought I might preload them at the bottom of the page...
(def setting-map
{:cafe "img/cafe.jpg"
:livingroom "img/livingroom.png"
:museum "img/museum.jpg"
:store "img/store.jpg"
:park "img/park.jpg"})
I get an "invalid arity: 0
yeah with #(x)
you're trying to call x
as a function, so in this case you're trying to call a vector as a function, which you can, calling a vector as a function gets you an element at a specific index, i.e. ([1 2 3] 0)
will give you 1
. But you're just calling the vector without any argument, i.e. incorrect arity.
with (fn [] x)
you're returning x
when the function is called. For both to be the same, you'd need to do (fn [] (x))
interesting