This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-02
Channels
- # beginners (98)
- # bigdata (1)
- # bitcoin (1)
- # boot (32)
- # cider (20)
- # cljs-dev (57)
- # cljsrn (130)
- # clojure (93)
- # clojure-dusseldorf (1)
- # clojure-germany (1)
- # clojure-greece (3)
- # clojure-italy (2)
- # clojure-russia (203)
- # clojure-spec (14)
- # clojure-uk (50)
- # clojurescript (127)
- # css (7)
- # cursive (6)
- # data-science (1)
- # datomic (4)
- # emacs (1)
- # events (1)
- # fulcro (8)
- # funcool (12)
- # graphql (7)
- # jobs (1)
- # lein-figwheel (2)
- # luminus (2)
- # off-topic (7)
- # om (16)
- # onyx (4)
- # parinfer (17)
- # pedestal (6)
- # portkey (36)
- # proton (3)
- # re-frame (10)
- # shadow-cljs (140)
- # spacemacs (12)
- # specter (1)
- # sql (1)
- # vim (10)
- # yada (10)
Ran into the same issues @wilkerlucio still haven’t found the way to do it correctly
@timovanderkamp if you figure out, please let me know... the only "solution" now is putting keys on everyone, but it's very annoying
and there are solutions around it, since re-frame custom components don't need that
Ive tried to pass a keyfn that either takes the given key or generates a unique one, but thats clearly not the way it should work
@timovanderkamp I found the problem, what generates this issue is the way the om factory
calls the React.createElement
if you use this custom factory method this problem can be avoided:
(defn factory
"Create a factory constructor from a component class created with
om.next/defui."
([class] (factory class nil))
([class {:keys [validator keyfn instrument?]
:or {instrument? true} :as opts}]
{:pre [(fn? class)]}
(fn self [props & children]
(when-not (nil? validator)
(assert (validator props)))
(if (and *instrument* instrument?)
(*instrument*
{:props props
:children children
:class class
:factory (factory class (assoc opts :instrument? false))})
(let [key (if-not (nil? keyfn)
(keyfn props)
(compute-react-key class props))
ref (:ref props)
ref (cond-> ref (keyword? ref) str)
t (if-not (nil? *reconciler*)
(p/basis-t *reconciler*)
0)]
(apply js/React.createElement class
#js {:key key
:ref ref
:omcljs$reactKey key
:omcljs$value (om-props props t)
:omcljs$path (-> props meta :om-path)
:omcljs$reconciler *reconciler*
:omcljs$parent *parent*
:omcljs$shared *shared*
:omcljs$instrument *instrument*
:omcljs$depth *depth*}
(or (util/force-children children) [])))))))
the problem was that, om.next factories are always sending the children as a single array to the element, by using an apply
at that points solves the problem
@wilkerlucio Thanks for this solution! Yet i find it so weird that it seems like not a lot of people run into this
disclaimer: still testing this one, just found some issues with other cases, trying to find one that works in all cases
I think most people do, and ignore it
Ye thats what i figured aswell
@timovanderkamp I realized something, after doing this all the key problems are gone, but if I try to (apply dom/div ...
I get some weird error, but just leaving the (om/children)
at the end now works fine
@wilkerlucio oh nice, i will try to use this and will tell you whenever i find difficulties with it
thanks
no problem, please let me know how it goes for you