Fork me on GitHub
#om
<
2017-10-03
>
souenzzo04:10:48

(defui UserList
  Object
  (render [this]
    (let [list (om/props list)]
      ;(apply dom/ul nil (map user list))
      (dom/div nil "ok")
      )))

(def user-list (om/factory UserList))

(defui Root
  static om/IQuery
  (query [this]
    [:app/counter :input/foo {:app/users (om/get-query User)}])
  Object
  (render [this]
    (let [{:keys [app/users]} (om/props this)]
      (apply dom/div nil
             [(dom/h2 nil "List A")
              (user-list users)
              ]))))
I'm trying to to this https://github.com/omcljs/om/wiki/Components,-Identity-&amp;-Normalization#something-to-look-at But getting Uncaught Error: Assert failed: (component? component) Then I comment (user-list users) everything renders ok.

levitanong06:10:08

@souenzzo Line 4: (om/props list) should be (om/props this)

levitanong06:10:28

You’re trying to get the om properties of cljs.core/list 😛

wilkerlucio11:10:13

yes, but this is a case for container components, a lot of the children don't have enough information to have a proper ident, for example a simple separator component

wilkerlucio11:10:00

also, after some investigation we noticed something weird, even if you don't use the children, sending a child without key to a component generated by an Om factory will trigger the problem

wilkerlucio11:10:42

like this:

(om/defui ^:once Container
  Object
  (render [this]
    (let [{:keys []} (om/props this)]
      (dom/div nil "A"))))

(def container (om/factory Container))

(om/defui ^:once Child
  Object
  (render [this]
    (let [{:keys []} (om/props this)]
      (dom/div nil "Im Child"))))

(def child (om/factory Child))

(defcard key-issue
  (fn []
    (container {}
      (child {}))))

wilkerlucio11:10:23

and in the end, this wazard can all be avoided, if when calling React.createElement we send then as position instead of a list, so to me seems like Om can solve

dirklectisch07:10:37

The fact that you get the error even if you don’t use the children is weird indeed. I imagined this would only trigger when they are in the actual render function.

dirklectisch06:10:43

After reading the react docs is personally just started assigning keys whenever I got that warning.

timovanderkamp06:10:44

@dirklectisch Normally you only need to supply a key when you are rendering a collection of elements. But for this example it is not necessary: (dom/div nil (dom/span nil "title") (my-button {})) If the container were a custom-component though, where you would render the children span and my-button by calling (om/children this) you would get the unique keys error.

timovanderkamp06:10:59

(my-dialog {} (dom/span nil "title") (my-button {}))

timovanderkamp06:10:22

Now you are forced to supply keys to all the children, which can be quite annoying