Problems with a recursive component running in Om?

I have the following:

(ns commentz.client (:require [om.core :as om :include-macros true] [om.dom :as dom :include-macros true] [clojure.browser.repl])) (def app-state (atom {:id "a" :value "I am the greatest of comments!" :user "1" :anonymous false :score 10 :children [{:value "I am ok too." :user "1" :anonymous false :score 4 :children [{:value "I am the second greatest comment" :user "2" :anonymous false :score 7 :children {}}]} {:value "I like turtles" :user "3" :anonymous true :score -3 :children {}}]})) (defn header [app owner] (dom/div #js {:className "header"} (dom/div #js {:className "vote"} (dom/div #js {:className "up"}) (dom/div #js {:className "down"})) (dom/a #js {:className "username" :href (:user app)} (:user-name app)) (dom/div #js {:className "score"} (:score app)))) (defn footer [app owner] (dom/div #js {:className "footer"} (dom/a #js {:className "permalink" :href (str "#" (:id app))} "permalink") (dom/a #js {:className "reply"} "reply"))) (defn comment [app owner] (reify om/IRender (render [this] (dom/div {:id (:id app) :className "comment"} (header app owner) (dom/div #js {:className "value"} (:value app)) (footer app owner) (om/build-all comment (:children app)))))) (om/root comment app-state {:target (. js/document (getElementById "app"))}) 

The above code compiles successfully, but I don't see anything recursive. Instead, I see the following when I test the browser.

 10 I am the greatest of comments! permalink reply 0 32374988 

I think 32374988 may be an object hash, not sure what 0. is. Anyway, my intention also sees that all 4 comments appear, with some comments embedded in others. At the moment, I get only the root comment, plus some weird 0 32374988 , where the comments should be recursively constructed. Any help is appreciated. Thanks.

+6
source share
1 answer

(om/build-all) returns seq. Try (apply dom/div nil ...) .

 (apply dom/div {:id (:id app) :className "comment"} (header app owner) (dom/div #js {:className "value"} (:value app)) (footer app owner) (om/build-all comment (:children app)))))) 
+7
source

All Articles