om

Please ask the channel first, not @dnolen directly!
timovanderkamp 2017-10-02T16:08:49.000163Z

Ran into the same issues @wilkerlucio still haven’t found the way to do it correctly

wilkerlucio 2017-10-02T16:09:39.000106Z

@timovanderkamp if you figure out, please let me know... the only "solution" now is putting keys on everyone, but it's very annoying

wilkerlucio 2017-10-02T16:10:03.000801Z

and there are solutions around it, since re-frame custom components don't need that

timovanderkamp 2017-10-02T16:11:48.000058Z

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

wilkerlucio 2017-10-02T17:51:36.000241Z

@timovanderkamp I found the problem, what generates this issue is the way the om factory calls the React.createElement

wilkerlucio 2017-10-02T17:51:51.000165Z

if you use this custom factory method this problem can be avoided:

wilkerlucio 2017-10-02T17:51:54.000111Z

(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) [])))))))

wilkerlucio 2017-10-02T17:52:40.000359Z

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

timovanderkamp 2017-10-02T17:55:15.000555Z

@wilkerlucio Thanks for this solution! Yet i find it so weird that it seems like not a lot of people run into this

wilkerlucio 2017-10-02T17:55:49.000497Z

disclaimer: still testing this one, just found some issues with other cases, trying to find one that works in all cases

wilkerlucio 2017-10-02T17:55:59.000651Z

I think most people do, and ignore it

timovanderkamp 2017-10-02T17:56:37.000691Z

Ye thats what i figured aswell

wilkerlucio 2017-10-02T18:02:54.000738Z

@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

timovanderkamp 2017-10-02T18:04:20.000519Z

@wilkerlucio oh nice, i will try to use this and will tell you whenever i find difficulties with it

timovanderkamp 2017-10-02T18:04:32.000374Z

thanks

wilkerlucio 2017-10-02T18:04:42.000164Z

no problem, please let me know how it goes for you