Fix 'unknown prop' react warning
This commit is contained in:
parent
c60db00f6d
commit
993b2a5064
|
@ -4,26 +4,28 @@
|
|||
|
||||
(defn input [{:keys [value-path] :as props}]
|
||||
(let [init-val @(rf/subscribe [:get-in value-path])
|
||||
props-clean (dissoc props :value-path)
|
||||
val (reagent/atom init-val)
|
||||
save #(let [v (-> @val str clojure.string/trim)]
|
||||
(when (seq v)
|
||||
(rf/dispatch [:assoc-in value-path v])))]
|
||||
(when (seq v)
|
||||
(rf/dispatch [:assoc-in value-path v])))]
|
||||
(fn []
|
||||
[:input.form-control
|
||||
(merge props {:type "text"
|
||||
:value @val
|
||||
:on-blur save
|
||||
:on-change #(reset! val (-> % .-target .-value))})])))
|
||||
(merge props-clean {:type "text"
|
||||
:value @val
|
||||
:on-blur save
|
||||
:on-change #(reset! val (-> % .-target .-value))})])))
|
||||
|
||||
(defn checkbox [{:keys [value-path on-change]}]
|
||||
(let [init-val @(rf/subscribe [:get-in value-path])
|
||||
val (reagent/atom init-val)]
|
||||
(fn [props]
|
||||
[:input.form-control
|
||||
(merge {:type "checkbox"
|
||||
:checked @val
|
||||
:onChange #(let [new-val (not @val)]
|
||||
(on-change)
|
||||
(rf/dispatch [:assoc-in value-path
|
||||
(reset! val new-val)]))}
|
||||
props)])))
|
||||
(let [props-clean (dissoc props :value-path)]
|
||||
[:input.form-control
|
||||
(merge {:type "checkbox"
|
||||
:checked @val
|
||||
:on-change #(let [new-val (not @val)]
|
||||
(on-change)
|
||||
(rf/dispatch [:assoc-in value-path
|
||||
(reset! val new-val)]))}
|
||||
props-clean)]))))
|
||||
|
|
Loading…
Reference in New Issue