Last active
October 2, 2020 14:26
-
-
Save giuseppeg/070f1603c5c5446f7f2f6f44c63e59b8 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
function Hydrator(props) { | |
const [isPaused, setIsPaused] = React.useState(typeof window !== "undefined"); | |
React.useEffect(() => { | |
console.log("Loading polyfills..."); | |
setTimeout(() => { | |
console.log("Done."); | |
setIsPaused(false); | |
}, 3000); | |
}, []); | |
return isPaused ? ( | |
<div dangerouslySetInnerHTML={{ __html: "" }} suppressHydrationWarning /> | |
) : ( | |
props.children | |
); | |
} | |
export default function MyApp({ Component, pageProps }) { | |
return ( | |
<Hydrator> | |
<div><Component {...pageProps} /></div> | |
</Hydrator> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment