mirror of https://github.com/status-im/reagent.git
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
|
||||
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])))
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
:dependencies [[org.clojure/clojure "1.8.0"]
|
||||
[org.clojure/clojurescript "1.8.51"]
|
||||
[cljsjs/react-dom "15.2.1-0"]
|
||||
[cljsjs/react-dom-server "15.2.1-0"]]
|
||||
[cljsjs/react-dom "15.4.0-0"]
|
||||
[cljsjs/react-dom-server "15.4.0-0"]]
|
||||
|
||||
:plugins [[lein-cljsbuild "1.1.3"]
|
||||
[codox "0.9.0"]]
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
[reagent.ratom :as ratom]
|
||||
[reagent.debug :as deb :refer-macros [dbg prn]]
|
||||
[reagent.interop :refer-macros [$ $!]]
|
||||
[reagent.dom :as dom]
|
||||
[reagent.dom.server :as server]))
|
||||
[reagent.dom :as dom]))
|
||||
|
||||
(def is-client util/is-client)
|
||||
|
||||
|
@ -79,20 +78,9 @@
|
|||
[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
|
||||
(def as-component as-element)
|
||||
(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
|
||||
"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.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
|
||||
|
|
Loading…
Reference in New Issue