Skip to content

Commit

Permalink
Revert "fix(antd-css): extract styles to avoid flush (#1057)"
Browse files Browse the repository at this point in the history
This reverts commit 6fcbd8d.
  • Loading branch information
sabertazimi committed Mar 8, 2023
1 parent 6fcbd8d commit c475f5b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 55 deletions.
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"codecov",
"codesandbox",
"combobox",
"cssinjs",
"flexbugs",
"gemoji",
"instanceof",
Expand Down
70 changes: 16 additions & 54 deletions pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,57 +1,19 @@
import { getSandpackCssText } from '@codesandbox/sandpack-react';
import Document, {
Head,
Html,
Main,
NextScript,
DocumentContext,
} from 'next/document';
import { createCache, extractStyle, StyleProvider } from '@ant-design/cssinjs';
import { Head, Html, Main, NextScript } from 'next/document';

export default class CustomDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
const cache = createCache();
const originalRenderPage = ctx.renderPage;
const Document = (): JSX.Element => (
<Html>
<Head>
<style
id="sandpack"
dangerouslySetInnerHTML={{ __html: getSandpackCssText() }}
/>
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);

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

const initialProps = await Document.getInitialProps(ctx);

return {
...initialProps,
styles: (
<>
{initialProps.styles}
<style
data-test="extract"
dangerouslySetInnerHTML={{ __html: extractStyle(cache) }}
/>
<style
id="sandpack"
dangerouslySetInnerHTML={{ __html: getSandpackCssText() }}
/>
</>
),
};
}

render() {
return (
<Html>
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
}
export default Document;

0 comments on commit c475f5b

Please sign in to comment.