Fork me on GitHub
James Conkling16:05:03

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 elements


totally unexpected for me, from what I’d expect vec version shouldn’t work :)

James Conkling17:05:10

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

James Conkling17:05:33

can’t I also pass a vector of tags? e.g. [:ul [[:li "one"] [:li "two"]]]?

James Conkling17:05:23

which is what I assumed (vec (repeat 2 [:li "thing"])) was doing

James Conkling17:05:04

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

👍 4