import React from 'react';
import Document, {
Html,
Main,
NextScript,
DocumentContext,
Head,
} from 'next/document';
import { ServerStyleSheets } from '@material-ui/styles';
export default class MyDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
// Render app and page and get the context of the page with collected side effects.
const sheets = new ServerStyleSheets();
const originalRenderPage = ctx.renderPage;
ctx.renderPage = () =>
originalRenderPage({
enhanceApp: App => props => sheets.collect(