Replace forceUpdate with shouldComponentUpdate

This commit is contained in:
Juho Teperi 2018-06-17 23:38:15 +03:00
parent 2825c8e172
commit c29276bc6b
1 changed files with 3 additions and 1 deletions

View File

@ -15,13 +15,15 @@
(fn [this [_ next-props]] (fn [this [_ next-props]]
(when (not= (:value next-props) (.-value (.-state this))) (when (not= (:value next-props) (.-value (.-state this)))
(.setState this #js {:value (:value next-props)}))) (.setState this #js {:value (:value next-props)})))
:should-component-update
(fn [this old-argv new-argv]
true)
:reagent-render :reagent-render
(fn [props & children] (fn [props & children]
(this-as this (this-as this
(let [props (-> props (let [props (-> props
(assoc :on-change (fn [e] (assoc :on-change (fn [e]
(.setState this #js {:value (.. e -target -value)}) (.setState this #js {:value (.. e -target -value)})
(.forceUpdate this)
(if-let [f (:on-change props)] (if-let [f (:on-change props)]
(f e))) (f e)))
:value (.-value (.-state this))) :value (.-value (.-state this)))