Fix dom-server calls in demo and text code

This commit is contained in:
Juho Teperi 2016-11-17 02:46:31 +02:00
parent 9d6359d816
commit 560f99174a
3 changed files with 10 additions and 13 deletions

View File

@ -276,7 +276,7 @@
[:p "Incidentally, this page also uses another React trick: the
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
the already present DOM tree."]])
@ -335,8 +335,3 @@
;; Show heavy examples on load, to make html file smaller
(when @show-all [complete-simple-demo])
(when @show-all [todomvc-demo])])))
#_(dotimes [_ 30]
(time
(r/render-to-string [main])))

View File

@ -2,6 +2,7 @@
(:require [clojure.string :as string]
[goog.events :as evt]
[reagent.core :as r]
[reagent.dom.server :as server]
[reagent.debug :refer-macros [dbg log dev?]]
[reagent.interop :as i :refer-macros [$ $!]])
(:import goog.History
@ -115,7 +116,7 @@
(defn html-template [{:keys [title body-html timestamp page-conf
js-file css-file main-div]}]
(let [main (str js-file timestamp)]
(r/render-to-static-markup
(server/render-to-static-markup
[:html
[:head
[:meta {:charset 'utf-8}]
@ -134,7 +135,7 @@
(emit [:set-page page-path])
(let [conf (merge conf @config)
b (:body conf)
bhtml (r/render-component-to-string b)]
bhtml (server/render-to-string b)]
(str "<!doctype html>\n"
(html-template (assoc conf
:page-conf {:page-path page-path}

View File

@ -4,6 +4,7 @@
[reagent.debug :as debug :refer-macros [dbg println log dev?]]
[reagent.interop :refer-macros [$ $!]]
[reagent.core :as r]
[reagent.dom.server :as server]
[reagent.impl.util :as util]))
(def tests-done (atom {}))
@ -269,7 +270,7 @@
(is (= 2 @ran)))))
(defn as-string [comp]
(r/render-component-to-string comp))
(server/render-to-string comp))
(deftest to-string-test []
(let [comp (fn [props]
@ -361,13 +362,13 @@
(deftest test-static-markup
(is (= "<div>foo</div>"
(r/render-to-static-markup
(server/render-to-static-markup
[:div "foo"])))
(is (= "<div class=\"bar\"><p>foo</p></div>"
(r/render-to-static-markup
(server/render-to-static-markup
[:div.bar [:p "foo"]])))
(is (= "<div class=\"bar\"><p>foobar</p></div>"
(r/render-to-static-markup
(server/render-to-static-markup
[:div.bar {:dangerously-set-inner-HTML
{:__html "<p>foobar</p>"}} ]))))
@ -432,7 +433,7 @@
(is (= 4 @ran)))))))
(defn rstr [react-elem]
(r/render-to-static-markup react-elem))
(server/render-to-static-markup react-elem))
(deftest test-create-element
(let [ae r/as-element