aboutsummaryrefslogtreecommitdiff
path: root/demos/css-stress-test/src/index.tsx
blob: 2676914673b079ed8d27e3c1b23a73053c09ee89 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import ReactDOMServer from "react-dom/server.browser";

import { Main } from "./main";
import classNames from "classnames";
const Base = ({}) => {
  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"));
}

function ssr() {
  console.log(ReactDOMServer.renderToString(<Base />));
}

if (typeof window !== "undefined") {
  console.log("HERE!!");
  globalThis.addEventListener("DOMContentLoaded", () => {
    startReact();
  });

  startReact();
} else {
  ssr();
}

export { Base };