Skip to content
Discussion options

You must be logged in to vote

I resolve it with adding

_document.tsx

CustomDocument.getInitialProps = async (ctx) => {
    const sheets = new ServerStyleSheets();
    const originalRenderPage = ctx.renderPage;

    ctx.renderPage = () =>
            originalRenderPage({
                enhanceApp: (App) => (props) => sheets.collect(<App {...props} />),
            });

    const initialProps = await Document.getInitialProps(ctx);

    return {
        ...initialProps,
        // Styles fragment is rendered after the app and page rendering finish.
        styles: [...React.Children.toArray(initialProps.styles), sheets.getStyleElement()],
    };
};

and theme.ts

const theme = createMuiTheme({
	palette: {
		primary: {
		…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@d3tr1tus
Comment options

@LukasBombach
Comment options

@d3tr1tus
Comment options

@d3tr1tus
Comment options

Comment options

You must be logged in to vote
1 reply
@timneutkens
Comment options

Answer selected by d3tr1tus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants