From 993b2a506498195bb7a1cd95e6b263042f16b917 Mon Sep 17 00:00:00 2001 From: Teemu Patja Date: Mon, 30 Jan 2017 21:34:12 +0200 Subject: [PATCH] Fix 'unknown prop' react warning --- src/cljs/commiteth/common.cljs | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/cljs/commiteth/common.cljs b/src/cljs/commiteth/common.cljs index 4312ec6..0bf7b61 100644 --- a/src/cljs/commiteth/common.cljs +++ b/src/cljs/commiteth/common.cljs @@ -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)]))))