I have a ClojureScript component:
(defn main-panel []
(def nodes (-> @(re-frame/subscribe [::subs/nodes])))
(defn list-nodes [node]
(prn (node :name)))
(reagent/create-class
{:component-did-mount
(fn []
(api-service/get-file-tree))
:reagent-render
(fn []
(doseq [node nodes]
(if (= (node :depth) 0)
(list-nodes node))))}))
which prints strings to the console.
But when I change the first function to:
(defn list-nodes [node]
[:<>
[:h1 (node :name)]])
I don't get any HTML that is rendered - no errors and the browser window stays blank.
How can I change this so it renders html?
Update
In response to the answer below I have changed doseq for for.
The issue is now that I am getting the error Uncaught Invariant Violation: Objects are not valid as a React child which is fine if you're working with React because you can debug, but with reagent, not so much. consider the following. This function:
(defn node [nodes]
(prn (nodes :name)))
when called by this function:
:reagent-render
(fn []
(for [nodes all-nodes]
(if (= (nodes :depth) 0)
(do
(nodeComponent/node nodes)
))))
prints 5 strings. But changing the called function to this:
(defn node [nodes]
[:h1 (nodes :name)])
causes this error: Uncaught Invariant Violation: Objects are not valid as a React child.
Is this problem somehow related to another problem I'm having?