mirror of
https://github.com/status-im/reagent.git
synced 2025-01-12 21:05:20 +00:00
Compare state with identical? in shouldComponentUpdate
And fix render bug
This commit is contained in:
parent
08d082e365
commit
89e7392269
@ -103,7 +103,7 @@
|
||||
|
||||
(defn- do-render [C f]
|
||||
(set! (.-isRenderContext ratom/*ratom-context*) true)
|
||||
(let [res (f (cljs-props C) f @C)
|
||||
(let [res (f (cljs-props C) C @C)
|
||||
conv (if (vector? res)
|
||||
(tmpl/as-component res)
|
||||
(if (fn? res)
|
||||
@ -141,12 +141,12 @@
|
||||
:shouldComponentUpdate
|
||||
(fn [C nextprops nextstate]
|
||||
(assert (nil? f) "shouldComponentUpdate is not yet supported")
|
||||
(assert (vector? (-> C .-props .-cljsArgs)))
|
||||
(let [a1 (-> C .-props .-cljsArgs)
|
||||
(let [a1 (args-of C)
|
||||
a2 (-> nextprops .-cljsArgs)
|
||||
ostate (.-cljsOldState C)
|
||||
eq (and (tmpl/equal-args a1 a2)
|
||||
(= ostate nextstate))]
|
||||
eq (and (identical? ostate nextstate)
|
||||
(tmpl/equal-args a1 a2))]
|
||||
(assert (vector? a1))
|
||||
(set! (.-cljsOldState C) nextstate)
|
||||
(not eq)))
|
||||
|
||||
|
@ -83,8 +83,8 @@
|
||||
true
|
||||
(let [props1 (nth v1 1)]
|
||||
(if (or (nil? props1) (map? props1))
|
||||
(and (= props1 (nth v2 1))
|
||||
(identical-parts v1 v2 2))
|
||||
(and (identical-parts v1 v2 2)
|
||||
(= props1 (nth v2 1)))
|
||||
(identical-parts v1 v2 1)))))))
|
||||
|
||||
(declare wrapper)
|
||||
|
@ -80,12 +80,6 @@
|
||||
(swap! C assoc :foo "there")
|
||||
(is (found-in #"hi there" div))
|
||||
|
||||
(let [runs @tests-run]
|
||||
;; should not be rendered
|
||||
(swap! C assoc :foo "there")
|
||||
(is (found-in #"hi there" div))
|
||||
(is (= runs @tests-run)))
|
||||
|
||||
(swap! C assoc :foo "you")
|
||||
(is (found-in #"hi you" div))))))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user