diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d18435..048309f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## Upcoming -- `render` now forces a deep update of all components by default, to make it more convenient to use with e.g. figwheel. +- `render` now forces a deep update of all components, to make it more convenient to use with e.g. figwheel. - Renamed `as-component` to `as-element`, to match React's new terminology better (old name still works, though, for backward compatiblity). diff --git a/src/reagent/core.cljs b/src/reagent/core.cljs index 541d068..8163459 100644 --- a/src/reagent/core.cljs +++ b/src/reagent/core.cljs @@ -6,7 +6,7 @@ [reagent.impl.util :as util] [reagent.impl.batching :as batch] [reagent.ratom :as ratom] - [reagent.debug :refer-macros [dbg prn]] + [reagent.debug :as deb :refer-macros [dbg prn]] [reagent.interop :refer-macros [.' .!]])) (def is-client util/is-client) @@ -48,19 +48,13 @@ either a vector (using Reagent's Hiccup syntax), or a React element. The second Optionally takes a callback that is called when the component is in place. -If the optional fourth argument is true (the default), an already mounted -component will be forced to re-render (by bypassing the default -shouldComponentUpdate). - Returns the mounted component instance." ([comp container] - (render comp container nil true)) + (render comp container nil)) ([comp container callback] - (render comp container callback true)) - ([comp container callback force-update] (let [f (fn [] (as-element (if (fn? comp) (comp) comp)))] - (util/render-component f container callback force-update)))) + (util/render-component f container callback)))) (defn unmount-component-at-node "Remove a component from the given DOM node." diff --git a/src/reagent/impl/util.cljs b/src/reagent/impl/util.cljs index 21eb6b9..83d64b9 100644 --- a/src/reagent/impl/util.cljs +++ b/src/reagent/impl/util.cljs @@ -100,7 +100,7 @@ (merge-style p1 (merge-class p1 (merge p1 p2)))))) -(declare ^:dynamic *always-update*) +(def ^:dynamic *always-update* false) (defonce roots (atom {})) @@ -113,9 +113,9 @@ (do (log "Error unmounting:") (log e))))) -(defn render-component [comp container callback force-update] +(defn render-component [comp container callback] (try - (binding [*always-update* force-update] + (binding [*always-update* true] (.' js/React render (comp) container (fn [] (binding [*always-update* false] @@ -127,7 +127,7 @@ (throw e))))) (defn re-render-component [comp container] - (render-component comp container nil true)) + (render-component comp container nil)) (defn unmount-component-at-node [container] (swap! roots dissoc container)