Initial commit

This commit is contained in:
Hazem Krimi
2021-01-04 14:31:06 +01:00
parent 15d215b278
commit 4708e5d074
15 changed files with 1041 additions and 263 deletions
+31
View File
@@ -0,0 +1,31 @@
import Document from 'next/document';
import { ServerStyleSheet } from 'styled-components';
class Doc extends Document {
static async getInitialProps(ctx) {
const sheet = new ServerStyleSheet();
const originalRenderPage = ctx.renderPage;
try {
ctx.renderPage = () =>
originalRenderPage({
enhanceApp: App => props => sheet.collectStyles(<App {...props} />)
});
const initialProps = await Document.getInitialProps(ctx);
return {
...initialProps,
styles: (
<>
{initialProps.styles}
{sheet.getStyleElement()}
</>
)
};
} finally {
sheet.seal();
}
}
}
export default Doc;