om

Please ask the channel first, not @dnolen directly!
souenzzo 2017-10-03T04:01:48.000088Z

(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-&-Normalization#something-to-look-at But getting Uncaught Error: Assert failed: (component? component) Then I comment (user-list users) everything renders ok.

levitanong 2017-10-03T06:10:08.000181Z

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

levitanong 2017-10-03T06:10:28.000042Z

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

👍 1
😳 1
dirklectisch 2017-10-03T06:21:43.000083Z

@timovanderkamp @wilkerlucio Are you aware that you can pass a keyfn to factory? Just checking. https://github.com/omcljs/om/wiki/Documentation-(om.next)#factory

wilkerlucio 2017-10-03T11:41:13.000122Z

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

wilkerlucio 2017-10-03T11:42:00.000102Z

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

wilkerlucio 2017-10-03T11:42:42.000088Z

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 {}))))

wilkerlucio 2017-10-03T11:43:23.000126Z

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

wilkerlucio 2017-10-03T11:43:38.000007Z

makes sense?

dirklectisch 2017-10-04T07:44:37.000404Z

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.

dirklectisch 2017-10-03T06:22:43.000039Z

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

timovanderkamp 2017-10-03T06:47:44.000292Z

@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.

timovanderkamp 2017-10-03T06:47:59.000113Z

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

timovanderkamp 2017-10-03T06:48:22.000273Z

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