-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- SSR-only now. entire html is rendered in JSX and hydrated into - using esm.sh for client react
- Loading branch information
Showing
15 changed files
with
103 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,10 @@ | ||
import React, { StrictMode } from "react"; | ||
import ReactDOM from "react-dom/client"; | ||
import { StrictMode } from "react"; | ||
import { hydrateRoot } from "react-dom/client"; | ||
import { App } from "./app.js"; | ||
|
||
const rootContainerId = "SITE_MAIN"; | ||
|
||
const container = | ||
document.getElementById(rootContainerId) ?? createContainer(document.body); | ||
|
||
const isSSR = container.hasAttribute("data-ssr"); | ||
const appElement = ( | ||
hydrateRoot( | ||
document, | ||
<StrictMode> | ||
<App renderType={isSSR ? "server-side" : "client-side"} /> | ||
<App /> | ||
</StrictMode> | ||
); | ||
|
||
if (isSSR) { | ||
ReactDOM.hydrateRoot(container, appElement); | ||
} else { | ||
ReactDOM.createRoot(container).render(appElement); | ||
} | ||
|
||
function createContainer(targetParent: Element) { | ||
const newContainer = document.createElement("div"); | ||
newContainer.id = rootContainerId; | ||
return targetParent.appendChild(newContainer); | ||
} |
Oops, something went wrong.