mirror of https://github.com/status-im/reagent.git
Flush ratom queue before rendering
Make sure outstanding reactions etc are up-to-date.
This commit is contained in:
parent
fe749392d7
commit
14366ccce3
|
@ -2,6 +2,7 @@
|
||||||
(:require [cljsjs.react.dom]
|
(:require [cljsjs.react.dom]
|
||||||
[reagent.impl.util :as util]
|
[reagent.impl.util :as util]
|
||||||
[reagent.impl.template :as tmpl]
|
[reagent.impl.template :as tmpl]
|
||||||
|
[reagent.ratom :as ratom]
|
||||||
[reagent.debug :refer-macros [dbg]]
|
[reagent.debug :refer-macros [dbg]]
|
||||||
[reagent.interop :refer-macros [$ $!]]))
|
[reagent.interop :refer-macros [$ $!]]))
|
||||||
|
|
||||||
|
@ -45,6 +46,7 @@
|
||||||
([comp container]
|
([comp container]
|
||||||
(render comp container nil))
|
(render comp container nil))
|
||||||
([comp container callback]
|
([comp container callback]
|
||||||
|
(ratom/flush!)
|
||||||
(let [f (fn []
|
(let [f (fn []
|
||||||
(tmpl/as-element (if (fn? comp) (comp) comp)))]
|
(tmpl/as-element (if (fn? comp) (comp) comp)))]
|
||||||
(render-comp f container callback))))
|
(render-comp f container callback))))
|
||||||
|
@ -70,6 +72,7 @@
|
||||||
ClojureScript). To get around this you'll have to introduce a layer
|
ClojureScript). To get around this you'll have to introduce a layer
|
||||||
of indirection, for example by using `(render [#'foo])` instead."
|
of indirection, for example by using `(render [#'foo])` instead."
|
||||||
[]
|
[]
|
||||||
|
(ratom/flush!)
|
||||||
(doseq [v (vals @roots)]
|
(doseq [v (vals @roots)]
|
||||||
(apply re-render-component v))
|
(apply re-render-component v))
|
||||||
"Updated")
|
"Updated")
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
(:require [cljsjs.react.dom.server]
|
(:require [cljsjs.react.dom.server]
|
||||||
[reagent.impl.util :as util]
|
[reagent.impl.util :as util]
|
||||||
[reagent.impl.template :as tmpl]
|
[reagent.impl.template :as tmpl]
|
||||||
|
[reagent.ratom :as ratom]
|
||||||
[reagent.interop :refer-macros [$ $!]]))
|
[reagent.interop :refer-macros [$ $!]]))
|
||||||
|
|
||||||
(defonce ^:private imported nil)
|
(defonce ^:private imported nil)
|
||||||
|
@ -20,11 +21,13 @@
|
||||||
(defn render-to-string
|
(defn render-to-string
|
||||||
"Turns a component into an HTML string."
|
"Turns a component into an HTML string."
|
||||||
[component]
|
[component]
|
||||||
|
(ratom/flush!)
|
||||||
(binding [util/*non-reactive* true]
|
(binding [util/*non-reactive* true]
|
||||||
($ (module) renderToString (tmpl/as-element component))))
|
($ (module) renderToString (tmpl/as-element component))))
|
||||||
|
|
||||||
(defn render-to-static-markup
|
(defn render-to-static-markup
|
||||||
"Turns a component into an HTML string, without data-react-id attributes, etc."
|
"Turns a component into an HTML string, without data-react-id attributes, etc."
|
||||||
[component]
|
[component]
|
||||||
|
(ratom/flush!)
|
||||||
(binding [util/*non-reactive* true]
|
(binding [util/*non-reactive* true]
|
||||||
($ (module) renderToStaticMarkup (tmpl/as-element component))))
|
($ (module) renderToStaticMarkup (tmpl/as-element component))))
|
||||||
|
|
Loading…
Reference in New Issue