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]
|
||||
[reagent.impl.util :as util]
|
||||
[reagent.impl.template :as tmpl]
|
||||
[reagent.ratom :as ratom]
|
||||
[reagent.debug :refer-macros [dbg]]
|
||||
[reagent.interop :refer-macros [$ $!]]))
|
||||
|
||||
|
@ -45,6 +46,7 @@
|
|||
([comp container]
|
||||
(render comp container nil))
|
||||
([comp container callback]
|
||||
(ratom/flush!)
|
||||
(let [f (fn []
|
||||
(tmpl/as-element (if (fn? comp) (comp) comp)))]
|
||||
(render-comp f container callback))))
|
||||
|
@ -70,6 +72,7 @@
|
|||
ClojureScript). To get around this you'll have to introduce a layer
|
||||
of indirection, for example by using `(render [#'foo])` instead."
|
||||
[]
|
||||
(ratom/flush!)
|
||||
(doseq [v (vals @roots)]
|
||||
(apply re-render-component v))
|
||||
"Updated")
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
(:require [cljsjs.react.dom.server]
|
||||
[reagent.impl.util :as util]
|
||||
[reagent.impl.template :as tmpl]
|
||||
[reagent.ratom :as ratom]
|
||||
[reagent.interop :refer-macros [$ $!]]))
|
||||
|
||||
(defonce ^:private imported nil)
|
||||
|
@ -20,11 +21,13 @@
|
|||
(defn render-to-string
|
||||
"Turns a component into an HTML string."
|
||||
[component]
|
||||
(ratom/flush!)
|
||||
(binding [util/*non-reactive* true]
|
||||
($ (module) renderToString (tmpl/as-element component))))
|
||||
|
||||
(defn render-to-static-markup
|
||||
"Turns a component into an HTML string, without data-react-id attributes, etc."
|
||||
[component]
|
||||
(ratom/flush!)
|
||||
(binding [util/*non-reactive* true]
|
||||
($ (module) renderToStaticMarkup (tmpl/as-element component))))
|
||||
|
|
Loading…
Reference in New Issue