anyone know why the following throws an error
(rum/defc repeat-label [n text]
[:div (repeat n [:.label text])])
;; throws "Objects are not valid as a React child"
while explicitly converting to a vector works:
(rum/defc repeat-label [n text]
[:div (vec (repeat n [:.label text]))])
In other instances I haven’t had issues rendering lazy sequences of elementstotally unexpected for me, from what I’d expect vec
version shouldn’t work :)
is vec
the correct way to coerce a lazy sequence to a vector? (into [] (repeat n [:.label text]))
also works
yes. The thing is, vectors are supposed to be tags and have special meaning when parsed, and anything sequential that’s not vector is supposed to be “list of stuff”
maybe report to sablono? I suspect it’s their compiler
can’t I also pass a vector of tags? e.g. [:ul [[:li "one"] [:li "two"]]]
?
which is what I assumed (vec (repeat 2 [:li "thing"]))
was doing
though [:ul (map (fn [n] [:li n]) (range 5))]
does work, so don’t know what the issue w/ repeat
is. ran into this while working on the tutorial in the README.
no, it must be [:ul (list [:li "one"] [:li "two"])]
because vectors are reserved for tags