Reuse render function between components

This commit is contained in:
Dan Holmsand 2014-11-22 17:05:43 +01:00
parent e4617bcaf6
commit 7d79637de6
1 changed files with 8 additions and 5 deletions

View File

@ -61,6 +61,13 @@
;;; Method wrapping ;;; Method wrapping
(def static-fns {:render
(fn []
(this-as c
(if-not *non-reactive*
(batch/run-reactively c #(do-render c))
(do-render c))))})
(defn custom-wrapper [key f] (defn custom-wrapper [key f]
(case key (case key
:getDefaultProps :getDefaultProps
@ -154,11 +161,7 @@
(defn add-render [fun-map render-f] (defn add-render [fun-map render-f]
(assoc fun-map (assoc fun-map
:cljsRender render-f :cljsRender render-f
:render (if-not *non-reactive* :render (:render static-fns)))
(fn []
(this-as c
(batch/run-reactively c #(do-render c))))
(fn [] (this-as c (do-render c))))))
(defn wrap-funs [fun-map] (defn wrap-funs [fun-map]
(let [render-fun (or (:componentFunction fun-map) (let [render-fun (or (:componentFunction fun-map)