Fork me on GitHub
#rum
<
2018-05-23
>
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

Niki16:05:26

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

Niki17:05:37

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”

Niki17:05:53

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.

Niki17:05:44

no, it must be [:ul (list [:li "one"] [:li "two"])]

Niki17:05:58

because vectors are reserved for tags

👍 4