From b964ec0fb697999cc756702dafb47d90438cb52b Mon Sep 17 00:00:00 2001 From: Juho Teperi Date: Mon, 31 Dec 2018 13:45:29 +0200 Subject: [PATCH] Fix render method --- src/reagent/impl/component.cljs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/reagent/impl/component.cljs b/src/reagent/impl/component.cljs index 1a8c550..707e009 100644 --- a/src/reagent/impl/component.cljs +++ b/src/reagent/impl/component.cljs @@ -294,7 +294,9 @@ [body] {:pre [(map? body)]} (let [body (cljsify body) - methods (map-to-js (apply dissoc body :displayName :getInitialState built-in-static-method-names)) + methods (map-to-js (apply dissoc body :displayName :getInitialState + :render :reagentRender :cljsLegacyRender + built-in-static-method-names)) static-methods (map-to-js (select-keys body built-in-static-method-names)) display-name (:displayName body) construct (:getInitialState body) @@ -304,7 +306,20 @@ (when construct (construct this)) this))] + (gobj/extend (.-prototype cmp) (.-prototype react/Component) methods) + + ;; These names SHOULD be mangled by Closure so we can't use goog/extend + + (when (:render body) + (set! (.-render (.-prototype cmp)) (:render body))) + + (when (:reagentRender body) + (set! (.-reagentRender (.-prototype cmp)) (:reagentRender body))) + + (when (:cljsLegacyRender body) + (set! (.-cljsLegacyRender (.-prototype cmp)) (:cljsLegacyRender body))) + (gobj/extend cmp react/Component static-methods) (when display-name