Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed document.js? #73

Open
wants to merge 3 commits into
base: upgrade-next
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions pages/_document.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ import Document, { Head, Main, NextScript } from 'next/document'
import { ServerStyleSheet } from 'styled-components'

export default class MyDocument extends Document {
render() {
static getInitialProps({ renderPage }) {
const sheet = new ServerStyleSheet()
const main = sheet.collectStyles(<Main />)
const page = renderPage(App => props => sheet.collectStyles(<App {...props} />))
const styleTags = sheet.getStyleElement()
return { ...page, styleTags }
}
render() {
return (
<html>
<Head>{styleTags}</Head>
<Head>{this.props.styleTags}</Head>
<body style={{ margin: 0 }}>
<div className="root">{main}</div>
<div className="root">
<Main />
</div>
<NextScript />
<script type="text/javascript" src="https://secure.leadforensics.com/js/113807.js" />
</body>
Expand Down