Last active
November 9, 2018 19:16
-
-
Save dearfrankg/531540b88c2a6cbaab208d56fe68a331 to your computer and use it in GitHub Desktop.
styled-components
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Document, { Head, Main, NextScript } from "next/document"; | |
import { ServerStyleSheet } from "styled-components"; | |
export default class MyDocument extends Document { | |
static getInitialProps({ renderPage }) { | |
const sheet = new ServerStyleSheet(); | |
const page = renderPage(App => props => | |
sheet.collectStyles(<App {...props} />) | |
); | |
const styleTags = sheet.getStyleElement(); | |
return { ...page, styleTags }; | |
} | |
render() { | |
return ( | |
<html> | |
<Head> | |
<title>nextjs project starter</title> | |
<meta | |
name="viewport" | |
content="initial-scale=1.0, width=device-width" | |
/> | |
{this.props.styleTags} | |
</Head> | |
<body> | |
<Main /> | |
<NextScript /> | |
</body> | |
</html> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
source: https://github.com/TrebuhD/nextjs-starter