Armen Nersisyan
Armen Nersisyan

Reputation: 61

How to solve the Flash of Unstyled Content in production?

I'm using NextJs for my app and I'm having a FOUC on production. I'm not using styled components, just moduled and global CSS/SCSS. I assume the problem may be from my _document.js file

import React from 'react';
import Document, {Html, Head, Main, NextScript} from 'next/document';

class MyDocument extends Document {
  static async getInitialProps(ctx) {
    const initialProps = await Document.getInitialProps(ctx);
    return {...initialProps};
  }

  render() {
    return (
      <Html>
        <Head>
          <link href="/static/scss/vendor/antd.css" rel="stylesheet" />
          <link href="/static/scss/vendor/bootstrap.min.css" rel="stylesheet" />
          <link href="/static/scss/base/typography.css" rel="stylesheet" />
          <link href="/static/scss/base/ionicons.min.css" rel="stylesheet" />
          <link href="/static/scss/base/flaticons.css" rel="stylesheet" />
          <link href="/static/scss/base/reset.css" rel="stylesheet" />
        </Head>
        <body>
          <div id="fb-root" />
          <Main />
          <NextScript />
        </body>
      </Html>
    );
  }
}

export default MyDocument;

Upvotes: 6

Views: 5639

Answers (0)

Related Questions