Remove four argument version of render for now

This commit is contained in:
Dan Holmsand 2014-12-09 13:29:26 +01:00
parent 0e8ca42a37
commit 54a4e28245
3 changed files with 8 additions and 14 deletions

View File

@ -3,7 +3,7 @@
## Upcoming ## 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). - Renamed `as-component` to `as-element`, to match React's new terminology better (old name still works, though, for backward compatiblity).

View File

@ -6,7 +6,7 @@
[reagent.impl.util :as util] [reagent.impl.util :as util]
[reagent.impl.batching :as batch] [reagent.impl.batching :as batch]
[reagent.ratom :as ratom] [reagent.ratom :as ratom]
[reagent.debug :refer-macros [dbg prn]] [reagent.debug :as deb :refer-macros [dbg prn]]
[reagent.interop :refer-macros [.' .!]])) [reagent.interop :refer-macros [.' .!]]))
(def is-client util/is-client) (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. 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." Returns the mounted component instance."
([comp container] ([comp container]
(render comp container nil true)) (render comp container nil))
([comp container callback] ([comp container callback]
(render comp container callback true))
([comp container callback force-update]
(let [f (fn [] (let [f (fn []
(as-element (if (fn? comp) (comp) comp)))] (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 (defn unmount-component-at-node
"Remove a component from the given DOM node." "Remove a component from the given DOM node."

View File

@ -100,7 +100,7 @@
(merge-style p1 (merge-class p1 (merge p1 p2)))))) (merge-style p1 (merge-class p1 (merge p1 p2))))))
(declare ^:dynamic *always-update*) (def ^:dynamic *always-update* false)
(defonce roots (atom {})) (defonce roots (atom {}))
@ -113,9 +113,9 @@
(do (log "Error unmounting:") (do (log "Error unmounting:")
(log e))))) (log e)))))
(defn render-component [comp container callback force-update] (defn render-component [comp container callback]
(try (try
(binding [*always-update* force-update] (binding [*always-update* true]
(.' js/React render (comp) container (.' js/React render (comp) container
(fn [] (fn []
(binding [*always-update* false] (binding [*always-update* false]
@ -127,7 +127,7 @@
(throw e))))) (throw e)))))
(defn re-render-component [comp container] (defn re-render-component [comp container]
(render-component comp container nil true)) (render-component comp container nil))
(defn unmount-component-at-node [container] (defn unmount-component-at-node [container]
(swap! roots dissoc container) (swap! roots dissoc container)