1

I generate 500 page in _error.js, when get errorCode ise 500 I want return special 500 page import.

There is no problem for my code, when user get 500 is saw my special 500 page, but css not working?

CSS is come in tag but not working

Here is my _error.js code :

import React from 'react'
import Error from 'next/error'
import PageInternal from './500'

const MyError = ({ statusCode, hasGetInitialPropsRun, err }) => {

  return <Error statusCode={statusCode} />

  function Error({ statusCode }) {
    if (statusCode === 500) return <PageInternal />
  }
}

MyError.getInitialProps = async ({ res, err, asPath }) => {
  const errorInitialProps = await Error.getInitialProps({ res, err })
  const statusCode = res ? res.statusCode : err ? err.statusCode : 404
.... bla
}

CSS is not working, also JSX not working. I don't understand

My custom 500 Component Pic

CSS not loading? Pic

My 500 component :

import React from 'react'
import DefaultLayout from 'components/layouts/default'
import './style.scss'

const PageInternal = (props) => {

  return (
    <DefaultLayout
      title="Problem"
      {...props}
    >
      <div className="page-internal">
        <div className="internal-image">500</div>
        <p>
          Technical Problems
        </p>
        <a className="btn btn-default btn-lg">Refresh Page</a>
      </div>
    </DefaultLayout>
  )
}
export default PageInternal
4
  • We'll need to see what's in ./500 as that's what get rendered. Could you update your question with that file? Commented Jan 15, 2021 at 11:22
  • @juliomalves I added pictures, pls help Commented Jan 15, 2021 at 11:36
  • Don't post images of code or error messages. Instead copy and paste or type the actual code/message into the post directly. Commented Jan 15, 2021 at 11:38
  • @juliomalves Ok, can you check again ? Commented Jan 15, 2021 at 11:58

1 Answer 1

1

if you use styles.component, you need update Next.js to 10+ version. More details here https://github.com/vercel/next.js/issues/16931

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.