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