Commit c6928dcf authored by Lukáš Huvar's avatar Lukáš Huvar Committed by Joe Haddad

Fix GIP type in `/_error` page (#7952)

parent 60b4e678
...@@ -121,10 +121,8 @@ export default function dynamic<P = {}>( ...@@ -121,10 +121,8 @@ export default function dynamic<P = {}>(
!(dynamicOptions instanceof Promise) !(dynamicOptions instanceof Promise)
) { ) {
// show deprecation warning for `modules` key in development // show deprecation warning for `modules` key in development
if ( if (process.env.NODE_ENV !== 'production') {
process.env.NODE_ENV !== 'production' if (dynamicOptions.modules) {
) {
if(dynamicOptions.modules) {
console.warn( console.warn(
'The modules option for next/dynamic has been deprecated. See here for more info https://err.sh/zeit/next.js/next-dynamic-modules' 'The modules option for next/dynamic has been deprecated. See here for more info https://err.sh/zeit/next.js/next-dynamic-modules'
) )
......
...@@ -20,9 +20,12 @@ export type ErrorProps = { ...@@ -20,9 +20,12 @@ export type ErrorProps = {
export default class Error<P = {}> extends React.Component<P & ErrorProps> { export default class Error<P = {}> extends React.Component<P & ErrorProps> {
static displayName = 'ErrorPage' static displayName = 'ErrorPage'
static getInitialProps({ res, err }: NextPageContext) { static getInitialProps({
res,
err,
}: NextPageContext): Promise<ErrorProps> | ErrorProps {
const statusCode = const statusCode =
res && res.statusCode ? res.statusCode : err ? err.statusCode : 404 res && res.statusCode ? res.statusCode : err ? err.statusCode! : 404
return { statusCode } return { statusCode }
} }
......
import { NextPageContext } from 'next'
import ErrorComponent from 'next/error'
class CustomError extends ErrorComponent {
static async getInitialProps({ res }: NextPageContext) {
const statusCode = 500
return { statusCode, title: 'CustomError' }
}
}
export default CustomError
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment