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}]
|
(defn input [{:keys [value-path] :as props}]
|
||||||
(let [init-val @(rf/subscribe [:get-in value-path])
|
(let [init-val @(rf/subscribe [:get-in value-path])
|
||||||
|
props-clean (dissoc props :value-path)
|
||||||
val (reagent/atom init-val)
|
val (reagent/atom init-val)
|
||||||
save #(let [v (-> @val str clojure.string/trim)]
|
save #(let [v (-> @val str clojure.string/trim)]
|
||||||
(when (seq v)
|
(when (seq v)
|
||||||
(rf/dispatch [:assoc-in value-path v])))]
|
(rf/dispatch [:assoc-in value-path v])))]
|
||||||
(fn []
|
(fn []
|
||||||
[:input.form-control
|
[:input.form-control
|
||||||
(merge props {:type "text"
|
(merge props-clean {:type "text"
|
||||||
:value @val
|
:value @val
|
||||||
:on-blur save
|
:on-blur save
|
||||||
:on-change #(reset! val (-> % .-target .-value))})])))
|
:on-change #(reset! val (-> % .-target .-value))})])))
|
||||||
|
|
||||||
(defn checkbox [{:keys [value-path on-change]}]
|
(defn checkbox [{:keys [value-path on-change]}]
|
||||||
(let [init-val @(rf/subscribe [:get-in value-path])
|
(let [init-val @(rf/subscribe [:get-in value-path])
|
||||||
val (reagent/atom init-val)]
|
val (reagent/atom init-val)]
|
||||||
(fn [props]
|
(fn [props]
|
||||||
[:input.form-control
|
(let [props-clean (dissoc props :value-path)]
|
||||||
(merge {:type "checkbox"
|
[:input.form-control
|
||||||
:checked @val
|
(merge {:type "checkbox"
|
||||||
:onChange #(let [new-val (not @val)]
|
:checked @val
|
||||||
(on-change)
|
:on-change #(let [new-val (not @val)]
|
||||||
(rf/dispatch [:assoc-in value-path
|
(on-change)
|
||||||
(reset! val new-val)]))}
|
(rf/dispatch [:assoc-in value-path
|
||||||
props)])))
|
(reset! val new-val)]))}
|
||||||
|
props-clean)]))))
|
||||||
|
|
Loading…
Reference in New Issue