Avoid duplicating :key in both wrapper and child

This commit is contained in:
Dan Holmsand 2014-02-12 07:16:55 +01:00
parent 12ee54b083
commit 7792f493c0
2 changed files with 14 additions and 14 deletions

View File

@ -73,8 +73,7 @@
[:div.color-samples
[:p n " random matching colors:"]
(map-indexed (fn [k v]
(with-meta [color-plate v]
{:key k}))
^{:key k} [color-plate v])
(take n @random-colors))]]))
(defn color-demo []

View File

@ -56,19 +56,20 @@
class))))
(defn convert-props [props id-class]
(let [is-empty (empty? props)]
(cond
(and is-empty (nil? id-class)) nil
(identical? (type props) js/Object) props
:else (let [objprops (js-obj)]
(when-not is-empty
(cond
(and (empty? props) (nil? id-class)) nil
(identical? (type props) js/Object) props
:else (let [objprops
(reduce-kv (fn [o k v]
(doto o (aset (cached-prop-name k)
(convert-prop-value v))))
objprops props))
(when-not (nil? id-class)
(set-id-class objprops id-class))
objprops))))
(let [pname (cached-prop-name k)]
(if-not (identical? pname "key")
;; Skip key, it is set by parent
(aset o pname (convert-prop-value v))))
o)
#js {} props)]
(when-not (nil? id-class)
(set-id-class objprops id-class))
objprops)))
(defn map-into-array [f arg coll]
(reduce (fn [a x]