This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-03
Channels
- # aleph (1)
- # beginners (42)
- # boot (34)
- # cider (157)
- # cljs-dev (12)
- # cljsrn (3)
- # clojure (165)
- # clojure-conj (1)
- # clojure-india (1)
- # clojure-italy (6)
- # clojure-russia (20)
- # clojure-spec (27)
- # clojure-uk (173)
- # clojurescript (116)
- # cursive (30)
- # datomic (87)
- # devcards (1)
- # docs (9)
- # emacs (2)
- # ethereum (2)
- # events (2)
- # fulcro (60)
- # graphql (10)
- # hoplon (2)
- # jobs-rus (6)
- # keechma (1)
- # lein-figwheel (9)
- # leiningen (36)
- # luminus (2)
- # mount (3)
- # off-topic (16)
- # om (14)
- # onyx (12)
- # pedestal (19)
- # portkey (107)
- # re-frame (9)
- # reagent (5)
- # ring (26)
- # shadow-cljs (149)
- # spacemacs (3)
- # sql (6)
(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.@souenzzo Line 4: (om/props list)
should be (om/props this)
You’re trying to get the om properties of cljs.core/list
😛
@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
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
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
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 {}))))
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
makes sense?
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.
After reading the react docs is personally just started assigning keys whenever I got that warning.
@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.
(my-dialog {}
(dom/span nil "title")
(my-button {}))
Now you are forced to supply keys to all the children, which can be quite annoying