diff options
Diffstat (limited to 'demos/css-stress-test/src')
-rw-r--r-- | demos/css-stress-test/src/index.tsx | 27 | ||||
-rw-r--r-- | demos/css-stress-test/src/main.tsx | 2 |
2 files changed, 20 insertions, 9 deletions
diff --git a/demos/css-stress-test/src/index.tsx b/demos/css-stress-test/src/index.tsx index 3db53a67f..267691467 100644 --- a/demos/css-stress-test/src/index.tsx +++ b/demos/css-stress-test/src/index.tsx @@ -1,20 +1,33 @@ -import ReactDOM from "react-dom"; -import React from "react"; +import ReactDOMServer from "react-dom/server.browser"; + import { Main } from "./main"; import classNames from "classnames"; - const Base = ({}) => { - const name = decodeURIComponent(location.search.substring(1)); + const name = + typeof location !== "undefined" + ? decodeURIComponent(location.search.substring(1)) + : null; return <Main productName={name || "Bundler"} />; }; function startReact() { + const ReactDOM = require("react-dom"); ReactDOM.render(<Base />, document.querySelector("#reactroot")); } -globalThis.addEventListener("DOMContentLoaded", () => { +function ssr() { + console.log(ReactDOMServer.renderToString(<Base />)); +} + +if (typeof window !== "undefined") { + console.log("HERE!!"); + globalThis.addEventListener("DOMContentLoaded", () => { + startReact(); + }); + startReact(); -}); -startReact(); +} else { + ssr(); +} export { Base }; diff --git a/demos/css-stress-test/src/main.tsx b/demos/css-stress-test/src/main.tsx index 1a9948fe8..c95d0f0eb 100644 --- a/demos/css-stress-test/src/main.tsx +++ b/demos/css-stress-test/src/main.tsx @@ -1,5 +1,3 @@ -import React from "react"; - export const Main = ({ productName }) => { return ( <> |