Determining the size of a component
As an Om neophyte, you might be wondering what the difference is between building subcomponents and just regular functions that return HTML. Let's look at a hypothetical choice borrowed from our previous todo list example:
(defn todo-item [cursor owner] (dom/div nil (dom/span #js {:className (when (:done? cursor) "done")} (:text )))))cursor)))) (defn todo-list [cursor owner] (reify om/IRender (render [_] (dom/div nil (dom/h1 nil (:text cursor)) (dom/div nil (for [t (:todos cursor)] (todo-item t owner))))))) ```
This is a slightly modified version of our previous todo application. Here, todo-item
is a standard function that happens to return virtual DOM nodes rather than an Om component constructor. It doesn't call reify
. The todo-list calls the function...