import React from "react"; import Document, { DocumentContext, DocumentInitialProps, Html, Head, Main, NextScript } from "next/document"; import { ServerStyleSheets } from "@material-ui/styles"; import { theme } from "../styles/MainTheme"; export default class extends Document { static getInitialProps = async (ctx: DocumentContext) => { const sheets = new ServerStyleSheets(); const originalRenderPage = ctx.renderPage; ctx.renderPage = () => originalRenderPage({ enhanceApp: App => props => sheets.collect() }); const initialProps = await Document.getInitialProps(ctx); return { ...initialProps, styles: [initialProps.styles, sheets.getStyleElement()] } as DocumentInitialProps; }; render() { return (
); } }