mirror of
https://github.com/status-im/reagent.git
synced 2025-01-13 21:34:29 +00:00
Merge pull request #276 from Deraen/react-15.4.0
Update to React 15.4.0 and drop dom-server functions from core
This commit is contained in:
commit
78ae18dce2
@ -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}
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
:dependencies [[org.clojure/clojure "1.8.0"]
|
:dependencies [[org.clojure/clojure "1.8.0"]
|
||||||
[org.clojure/clojurescript "1.8.51"]
|
[org.clojure/clojurescript "1.8.51"]
|
||||||
[cljsjs/react-dom "15.2.1-0"]
|
[cljsjs/react-dom "15.4.0-0"]
|
||||||
[cljsjs/react-dom-server "15.2.1-0"]]
|
[cljsjs/react-dom-server "15.4.0-0"]]
|
||||||
|
|
||||||
:plugins [[lein-cljsbuild "1.1.3"]
|
:plugins [[lein-cljsbuild "1.1.3"]
|
||||||
[codox "0.9.0"]]
|
[codox "0.9.0"]]
|
||||||
|
@ -8,8 +8,7 @@
|
|||||||
[reagent.ratom :as ratom]
|
[reagent.ratom :as ratom]
|
||||||
[reagent.debug :as deb :refer-macros [dbg prn]]
|
[reagent.debug :as deb :refer-macros [dbg prn]]
|
||||||
[reagent.interop :refer-macros [$ $!]]
|
[reagent.interop :refer-macros [$ $!]]
|
||||||
[reagent.dom :as dom]
|
[reagent.dom :as dom]))
|
||||||
[reagent.dom.server :as server]))
|
|
||||||
|
|
||||||
(def is-client util/is-client)
|
(def is-client util/is-client)
|
||||||
|
|
||||||
@ -79,20 +78,9 @@
|
|||||||
[container]
|
[container]
|
||||||
(dom/unmount-component-at-node container))
|
(dom/unmount-component-at-node container))
|
||||||
|
|
||||||
(defn render-to-string
|
|
||||||
"Turns a component into an HTML string."
|
|
||||||
[component]
|
|
||||||
(server/render-to-string component))
|
|
||||||
|
|
||||||
;; For backward compatibility
|
;; For backward compatibility
|
||||||
(def as-component as-element)
|
(def as-component as-element)
|
||||||
(def render-component render)
|
(def render-component render)
|
||||||
(def render-component-to-string render-to-string)
|
|
||||||
|
|
||||||
(defn render-to-static-markup
|
|
||||||
"Turns a component into an HTML string, without data-react-id attributes, etc."
|
|
||||||
[component]
|
|
||||||
(server/render-to-static-markup component))
|
|
||||||
|
|
||||||
(defn ^:export force-update-all
|
(defn ^:export force-update-all
|
||||||
"Force re-rendering of all mounted Reagent components. This is
|
"Force re-rendering of all mounted Reagent components. This is
|
||||||
|
@ -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…
x
Reference in New Issue
Block a user