Created
June 14, 2019 22:03
-
-
Save theednaffattack/e9c3b8808ee94cf5112d9fb37727edf2 to your computer and use it in GitHub Desktop.
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
const React = require("react") | |
const ReactDOM = require("react-dom") | |
const Meep = ( | |
<div | |
style={{ backgroundColor: "blue", fontColor: "white" }} | |
onClick={() => alert("hello")} | |
> | |
Hello world? | |
</div> | |
) | |
module.exports = { Meep } | |
const SSR = ( | |
<div | |
style={{ backgroundColor: "blue", fontColor: "white" }} | |
onClick={() => alert("hello")} | |
> | |
Hello world? | |
</div> | |
) | |
module.exports = { SSR: SSRComp } | |
const isServer = typeof document === "undefined" | |
console.log("isBrowser help") | |
console.log(isServer) | |
// Render only in the browser, export otherwise | |
if (typeof document === "undefined") { | |
module.exports = SSR | |
} else { | |
ReactDOM.hydrate(SSR, document.getElementById("app")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment