Me enfrento a ese problema en mi nueva aplicación nextjs. El problema comenzó a manifestarse cuando usé accesorios para agregar un carrusel a mi proyecto. Da un problema que el originalRenderPage en Document.js no está definido. Gracias por tu ayuda
Server Error TypeError: Cannot read properties of undefined (reading 'ref') This error happened while generating the page. Any console logs will be displayed in the terminal window. Source pages\_document.js (26:25) @ Object.ctx.renderPage 24 | const originalRenderPage = ctx.renderPage 25 | > 26 | ctx.renderPage = () => originalRenderPage({ | ^ 27 | enhanceApp: WrappedComponent => props => sheets.collect(<WrappedComponent {...props} />) 28 | }) import React, { Fragment } from 'react' import Document, { Head, Main, NextScript } from 'next/document' import { ServerStyleSheets } from '@material-ui/styles' import {Html} from "next/document"; class _Document extends Document { render () { return ( <Html lang='pt-BR' dir='ltr'> <Head> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" /> </Head> <body> <Main /> <NextScript /> </body> </Html> ) } } _Document.getInitialProps = async ctx => { const sheets = new ServerStyleSheets() const originalRenderPage = ctx.renderPage ctx.renderPage = () => originalRenderPage({ enhanceApp: WrappedComponent => props => sheets.collect(<WrappedComponent {...props} />) }) const initialProps = await Document.getInitialProps(ctx) return { ...initialProps, styles: [...React.Children.toArray(initialProps.styles), sheets.getStyleElement()] } } export default _Documenteste es tu error
TypeError: Cannot read properties of undefined (reading 'ref')
Está sucediendo debido a esta línea
const sheets = new ServerStyleSheets()
arreglarlo a
const sheets = new ServerStyleSheet()