Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

198
Vistas
originalRenderPage is not defined

I am facing such issue in my new nextjs app. The problem started to show itself when I used props to add a carousel to my project. It gives a problem that the originalRenderPage in Document.js is not defined. Thanks for your help

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 _Document
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This is your error

TypeError: Cannot read properties of undefined (reading 'ref')

It's happening because of this line

const sheets = new ServerStyleSheets()

Fix it to

const sheets = new ServerStyleSheet()

https://styled-components.com/docs/advanced#example

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda