Skip to content

Instantly share code, notes, and snippets.

@giuseppeg
Last active October 2, 2020 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giuseppeg/070f1603c5c5446f7f2f6f44c63e59b8 to your computer and use it in GitHub Desktop.
Save giuseppeg/070f1603c5c5446f7f2f6f44c63e59b8 to your computer and use it in GitHub Desktop.
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