If you defined a pages/_document.js with getInitialProps, and return styles, you get this error when loading the app with ?amp=1 in the URL:
Error: Cannot read property '__html' of undefined when defining a custom Document.getInitialProps
Use the _document.js from Material UI's example here: https://github.com/mui-org/material-ui/blob/master/examples/nextjs/pages/_document.js
The error goes away if you comment out:
styles: [
<React.Fragment key="styles">
{initialProps.styles}
{sheets.getStyleElement()}
</React.Fragment>,
],
An AMP response should be rendered without error.
Going to close this issue as it hasn't had activity for a few months. I believe the issue has been fixed by Olivier 馃憤
Most helpful comment
related:
https://github.com/zeit/next.js/issues/9041
https://github.com/zeit/next.js/issues/7856