Skip to content

Commit

Permalink
From js/ReactDOMServer -> react-dom/server's renderToString
Browse files Browse the repository at this point in the history
Use proper require of react-dom/server and invoke its renderToString,
instead of accessing the global js/ReactDOMServer, which might not be available.

I had troubles making sure that `js/ReactDOMServer` and thus couldn't render to a string.
With this change, it works fine.
  • Loading branch information
holyjak committed Sep 23, 2023
1 parent 125884b commit 931762b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/com/fulcrologic/fulcro/dom.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[com.fulcrologic.fulcro.components :as comp]
["react" :as react]
["react-dom" :as react.dom]
["react-dom/server" :as react-dom-server]
[goog.object :as gobj]
[goog.dom :as gdom]
[com.fulcrologic.fulcro.dom.inputs :as inputs]
Expand Down Expand Up @@ -72,9 +73,9 @@
(react.dom/render component el))

(defn render-to-str
"Equivalent to React.renderToString. NOTE: You must make sure js/ReactDOMServer is defined (e.g. require cljsjs.react.dom.server) to use this function."
"Equivalent to React.renderToString."
[c]
(js/ReactDOMServer.renderToString c))
(react-dom-server/renderToString c))

(defn node
"Returns the dom node associated with a component's React ref."
Expand Down

0 comments on commit 931762b

Please sign in to comment.