mirror of https://github.com/status-im/reagent.git
Fix dom-server calls in demo and text code
This commit is contained in:
parent
9d6359d816
commit
560f99174a
|
@ -276,7 +276,7 @@
|
||||||
|
|
||||||
[:p "Incidentally, this page also uses another React trick: the
|
[:p "Incidentally, this page also uses another React trick: the
|
||||||
entire page is pre-rendered using Node, and "
|
entire page is pre-rendered using Node, and "
|
||||||
[:code "reagent.core/render-component-to-string"] ". When it is loaded
|
[:code "reagent.dom.server/render-to-string"] ". When it is loaded
|
||||||
into the browser, React automatically attaches event-handlers to
|
into the browser, React automatically attaches event-handlers to
|
||||||
the already present DOM tree."]])
|
the already present DOM tree."]])
|
||||||
|
|
||||||
|
@ -335,8 +335,3 @@
|
||||||
;; Show heavy examples on load, to make html file smaller
|
;; Show heavy examples on load, to make html file smaller
|
||||||
(when @show-all [complete-simple-demo])
|
(when @show-all [complete-simple-demo])
|
||||||
(when @show-all [todomvc-demo])])))
|
(when @show-all [todomvc-demo])])))
|
||||||
|
|
||||||
|
|
||||||
#_(dotimes [_ 30]
|
|
||||||
(time
|
|
||||||
(r/render-to-string [main])))
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
(:require [clojure.string :as string]
|
(:require [clojure.string :as string]
|
||||||
[goog.events :as evt]
|
[goog.events :as evt]
|
||||||
[reagent.core :as r]
|
[reagent.core :as r]
|
||||||
|
[reagent.dom.server :as server]
|
||||||
[reagent.debug :refer-macros [dbg log dev?]]
|
[reagent.debug :refer-macros [dbg log dev?]]
|
||||||
[reagent.interop :as i :refer-macros [$ $!]])
|
[reagent.interop :as i :refer-macros [$ $!]])
|
||||||
(:import goog.History
|
(:import goog.History
|
||||||
|
@ -115,7 +116,7 @@
|
||||||
(defn html-template [{:keys [title body-html timestamp page-conf
|
(defn html-template [{:keys [title body-html timestamp page-conf
|
||||||
js-file css-file main-div]}]
|
js-file css-file main-div]}]
|
||||||
(let [main (str js-file timestamp)]
|
(let [main (str js-file timestamp)]
|
||||||
(r/render-to-static-markup
|
(server/render-to-static-markup
|
||||||
[:html
|
[:html
|
||||||
[:head
|
[:head
|
||||||
[:meta {:charset 'utf-8}]
|
[:meta {:charset 'utf-8}]
|
||||||
|
@ -134,7 +135,7 @@
|
||||||
(emit [:set-page page-path])
|
(emit [:set-page page-path])
|
||||||
(let [conf (merge conf @config)
|
(let [conf (merge conf @config)
|
||||||
b (:body conf)
|
b (:body conf)
|
||||||
bhtml (r/render-component-to-string b)]
|
bhtml (server/render-to-string b)]
|
||||||
(str "<!doctype html>\n"
|
(str "<!doctype html>\n"
|
||||||
(html-template (assoc conf
|
(html-template (assoc conf
|
||||||
:page-conf {:page-path page-path}
|
:page-conf {:page-path page-path}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
[reagent.debug :as debug :refer-macros [dbg println log dev?]]
|
[reagent.debug :as debug :refer-macros [dbg println log dev?]]
|
||||||
[reagent.interop :refer-macros [$ $!]]
|
[reagent.interop :refer-macros [$ $!]]
|
||||||
[reagent.core :as r]
|
[reagent.core :as r]
|
||||||
|
[reagent.dom.server :as server]
|
||||||
[reagent.impl.util :as util]))
|
[reagent.impl.util :as util]))
|
||||||
|
|
||||||
(def tests-done (atom {}))
|
(def tests-done (atom {}))
|
||||||
|
@ -269,7 +270,7 @@
|
||||||
(is (= 2 @ran)))))
|
(is (= 2 @ran)))))
|
||||||
|
|
||||||
(defn as-string [comp]
|
(defn as-string [comp]
|
||||||
(r/render-component-to-string comp))
|
(server/render-to-string comp))
|
||||||
|
|
||||||
(deftest to-string-test []
|
(deftest to-string-test []
|
||||||
(let [comp (fn [props]
|
(let [comp (fn [props]
|
||||||
|
@ -361,13 +362,13 @@
|
||||||
|
|
||||||
(deftest test-static-markup
|
(deftest test-static-markup
|
||||||
(is (= "<div>foo</div>"
|
(is (= "<div>foo</div>"
|
||||||
(r/render-to-static-markup
|
(server/render-to-static-markup
|
||||||
[:div "foo"])))
|
[:div "foo"])))
|
||||||
(is (= "<div class=\"bar\"><p>foo</p></div>"
|
(is (= "<div class=\"bar\"><p>foo</p></div>"
|
||||||
(r/render-to-static-markup
|
(server/render-to-static-markup
|
||||||
[:div.bar [:p "foo"]])))
|
[:div.bar [:p "foo"]])))
|
||||||
(is (= "<div class=\"bar\"><p>foobar</p></div>"
|
(is (= "<div class=\"bar\"><p>foobar</p></div>"
|
||||||
(r/render-to-static-markup
|
(server/render-to-static-markup
|
||||||
[:div.bar {:dangerously-set-inner-HTML
|
[:div.bar {:dangerously-set-inner-HTML
|
||||||
{:__html "<p>foobar</p>"}} ]))))
|
{:__html "<p>foobar</p>"}} ]))))
|
||||||
|
|
||||||
|
@ -432,7 +433,7 @@
|
||||||
(is (= 4 @ran)))))))
|
(is (= 4 @ran)))))))
|
||||||
|
|
||||||
(defn rstr [react-elem]
|
(defn rstr [react-elem]
|
||||||
(r/render-to-static-markup react-elem))
|
(server/render-to-static-markup react-elem))
|
||||||
|
|
||||||
(deftest test-create-element
|
(deftest test-create-element
|
||||||
(let [ae r/as-element
|
(let [ae r/as-element
|
||||||
|
|
Loading…
Reference in New Issue