Ensure adapt-input-component works with uncontrolled inputs

This commit is contained in:
Juho Teperi 2018-06-17 23:42:09 +03:00
parent c29276bc6b
commit dca635e3b0
1 changed files with 6 additions and 5 deletions

View File

@ -22,11 +22,12 @@
(fn [props & children]
(this-as this
(let [props (-> props
(assoc :on-change (fn [e]
(.setState this #js {:value (.. e -target -value)})
(if-let [f (:on-change props)]
(f e)))
:value (.-value (.-state this)))
(cond-> (:on-change props)
(assoc :on-change (fn [e]
(.setState this #js {:value (.. e -target -value)})
((:on-change props) e))))
(cond-> (:value props)
(assoc :value (.-value (.-state this))))
rtpl/convert-prop-value)]
(apply r/create-element component props (map r/as-element children)))))}) ))