Only pass key and ref to react if necessary

This commit is contained in:
Dan Holmsand 2013-12-20 19:21:41 +01:00
parent 9344edc7da
commit 42f392f208
1 changed files with 6 additions and 4 deletions

View File

@ -132,8 +132,10 @@
a (js-obj)] a (js-obj)]
(set! (.-cljsArgs a) x) (set! (.-cljsArgs a) x)
(when (map? p) (when (map? p)
(set! (.-key a) (:key p)) (when-let [key (:key p)]
(set! (.-ref a) (:ref p))) (set! (.-key a) key))
(when-let [ref (:ref p)]
(set! (.-ref a) ref)))
(c a))) (c a)))
(defn map-into-array [f coll] (defn map-into-array [f coll]
@ -151,7 +153,7 @@
(def cached-tag (memoize parse-tag)) (def cached-tag (memoize parse-tag))
(defn render-wrapped [this] (defn render-wrapped [this]
(let [inprops (aget this "props") #_(.-props this) (let [inprops (aget this "props")
args (.-cljsArgs inprops) args (.-cljsArgs inprops)
[tag scnd] args [tag scnd] args
hasprops (or (nil? scnd) (map? scnd)) hasprops (or (nil? scnd) (map? scnd))
@ -166,7 +168,7 @@
(.apply f nil (.concat (array jsprops) jsargs)))) (.apply f nil (.concat (array jsprops) jsargs))))
(defn should-update-wrapped [C nextprops nextstate] (defn should-update-wrapped [C nextprops nextstate]
(let [a1 (-> C (aget "props") #_.-props .-cljsArgs) (let [a1 (-> C (aget "props") .-cljsArgs)
a2 (-> nextprops .-cljsArgs)] a2 (-> nextprops .-cljsArgs)]
(not (equal-args a1 a2)))) (not (equal-args a1 a2))))