Unable to display two components in OM

I'm trying to find out Om, and came across something that I do not understand. I would expect this code

(defn search-page-view [app owner]
(reify
    om/IRender
    (render [_]
      (dom/div #js {:id "search-block"}
                  "Test")
      (dom/div #js {:id "results-block"}
               "Test2"))))
(om/root
 search-page-view app-state
  {:target (. js/document (getElementById "app"))})

to get this html:

<div id="app>
  <div id="search-block">
    Test
  </div>
  <div id="results-block">
    Test2
  </div>
</div>

However, it is not! The first test test is divnot displayed. What? I do not understand?

Edit using solution (indicated by FakeRainBrigand):

Change code to

(defn search-page-view [app owner]
  (reify
    om/IRender
    (render [_]
      (dom/div nil
               (dom/div #js {:id "search-block"}
                    "Test")
               (dom/div #js {:id "results-block"}
                    "Test2")))))

leads to the expected html.

+4
source share
1 answer

As explained here and explained by FakeRainBrigand, your render function should return a single render.

+2
source

Source: https://habr.com/ru/post/1546269/


All Articles