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]]
(when (not= (:value next-props) (.-value (.-state this)))
(.setState this #js {:value (:value next-props)})))
:should-component-update
(fn [this old-argv new-argv]
true)
:reagent-render
(fn [props & children]
(this-as this
(let [props (-> props
(assoc :on-change (fn [e]
(.setState this #js {:value (.. e -target -value)})
(.forceUpdate this)
(if-let [f (:on-change props)]
(f e)))
:value (.-value (.-state this)))