From 017fa9c10624eddddf1406e55bee101e9b18a882 Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Wed, 4 Feb 2015 22:45:39 +0100 Subject: [PATCH] Rename :component-function to :reagent-render But keep :component-function as alias for the time being --- src/reagent/impl/component.cljs | 13 +++++++++---- test/testreagent.cljs | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/reagent/impl/component.cljs b/src/reagent/impl/component.cljs index 19d0f50..9dd2b3c 100644 --- a/src/reagent/impl/component.cljs +++ b/src/reagent/impl/component.cljs @@ -28,7 +28,7 @@ (let [f (.' c :cljsRender) _ (assert (ifn? f)) p (.' c :props) - res (if (nil? (.' c :componentFunction)) + res (if (nil? (.' c :reagentRender)) (f c) (let [argv (.' p :argv) n (count argv)] @@ -118,7 +118,7 @@ (this-as c (apply f c args))) f)) -(def dont-wrap #{:cljsRender :render :componentFunction :cljsName}) +(def dont-wrap #{:cljsRender :render :reagentRender :cljsName}) (defn dont-bind [f] (if (fn? f) @@ -157,8 +157,13 @@ (assoc fm :cljsName (fn [] name)) fm))) -(defn wrap-funs [fun-map] - (let [render-fun (or (:componentFunction fun-map) +(defn wrap-funs [fmap] + (let [fun-map (if-some [cf (:componentFunction fmap)] + (-> fmap + (assoc :reagentRender cf) + (dissoc :componentFunction)) + fmap) + render-fun (or (:reagentRender fun-map) (:render fun-map)) _ (assert (ifn? render-fun) (str "Render must be a function, not " diff --git a/test/testreagent.cljs b/test/testreagent.cljs index 35906eb..c230bbf 100644 --- a/test/testreagent.cljs +++ b/test/testreagent.cljs @@ -76,7 +76,7 @@ self (atom nil) comp (reagent/create-class {:get-initial-state (fn [] {:foo "initial"}) - :render + :reagent-render (fn [] (let [this (reagent/current-component)] (reset! self this)