Next.js: _document.js - TypeError: Cannot read property 'map' of undefined

Created on 29 Apr 2017  ·  6Comments  ·  Source: vercel/next.js

nextjs: version 2.2.0

When I used _document.js like document mentioned. I have this issue. Is there any solution for this case?

I tried some examples using _document.js. It is still the same

bug

Most helpful comment

This problem will occur when nextjs version is 2.3-alpha1,
working good when 2.2.0

All 6 comments

@nndung179 is it possible to have a repo with a way for us to reproduce?

node version: 6.5.0
Hi @arunoda

Here is an example:

https://github.com/zeit/next.js/tree/master/examples/with-external-scoped-css

@arunoda I try this example using "next": "2.2.0" works fine.

captura de pantalla 2017-04-30 a las 9 23 44

But using "next": "latest", installs "2.3.0-alpha1", and tends to fail.

captura de pantalla 2017-04-30 a las 9 27 59

Adding this in _document.js works fine. source
```javascript
static getInitialProps ({ renderPage }) {
const {html, head, chunks} = renderPage()
return { html, head , chunks}
}

This problem will occur when nextjs version is 2.3-alpha1,
working good when 2.2.0

I assume this is same as this one: https://github.com/zeit/next.js/issues/2435
Always, try to add the correct stuff for getInitialProps of the custom docs. (Always refer to docs)

Or use this:

import Document from `next/document`

static getInitialProps (ctx) {
   return Document.getInitialProps(ctx)
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

irrigator picture irrigator  ·  3Comments

pie6k picture pie6k  ·  3Comments

YarivGilad picture YarivGilad  ·  3Comments

swrdfish picture swrdfish  ·  3Comments

jesselee34 picture jesselee34  ·  3Comments