This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-09
Channels
- # announcements (23)
- # asami (25)
- # babashka (38)
- # beginners (53)
- # calva (17)
- # clara (5)
- # clj-commons (1)
- # clj-kondo (18)
- # clojure (11)
- # clojure-europe (17)
- # clojure-france (1)
- # clojure-germany (5)
- # clojure-nl (2)
- # clojure-sg (4)
- # conjure (3)
- # deps-new (6)
- # fulcro (16)
- # off-topic (46)
- # pedestal (11)
- # react (2)
- # reagent (5)
- # reclojure (7)
- # rewrite-clj (1)
- # sci (18)
- # shadow-cljs (75)
- # sql (3)
- # xtdb (12)
I have a simple react-component that takes some variable number of args, like this:
[(r/adapt-react-class Stuff)
{:args :whatever}
[item1]
[item2]
[item3]]
Now, I want to supply those items as a list, how can I use apply (for instance) to make this work?Just to be clear, I want to achieve something along the following
(let [items [[item1][item2][item3]]]
[(r/adapt-react-class Stuff)
{:args :whatever}
...items?...]
Use into
.
Also, you can replace (r/adapt-react-class Stuff)
with :> Stuff
. Alternatively, move (r/adapt-react-class Stuff)
to an outer def
to avoid calling that function on each render (the function is cheap, but it's still an extra call).
And if items
is a real list and not a vector, you can just supply it as is. React might complain about a missing :key
(not sure if that's only for lazy collections or for regular lists as well). In that case, either provide :key
if it's possible to use an organic key and not a synthetic one, or just use into
.