diff options
author | 2021-06-29 17:47:58 -0700 | |
---|---|---|
committer | 2021-06-29 17:47:58 -0700 | |
commit | 3f197d1ce0c197864ad4c7c7b8238af4370275b4 (patch) | |
tree | 7d76dcc182e80c5b67db1568e769977229649980 /demos/css-stress-test/src/index.tsx | |
parent | 26745bb5f300481fc242c8e81de6f252f698c863 (diff) | |
download | bun-3f197d1ce0c197864ad4c7c7b8238af4370275b4.tar.gz bun-3f197d1ce0c197864ad4c7c7b8238af4370275b4.tar.zst bun-3f197d1ce0c197864ad4c7c7b8238af4370275b4.zip |
Fix crash, fix detecting node_modules, fix undefined not being simplified
Diffstat (limited to 'demos/css-stress-test/src/index.tsx')
-rw-r--r-- | demos/css-stress-test/src/index.tsx | 27 |
1 files changed, 20 insertions, 7 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 }; |