import React from 'react' import PropTypes from 'prop-types' import HTTPStatus from 'http-status' import Head from './head' export default class Error extends React.Component { static getInitialProps ({ res, err }) { const statusCode = res ? res.statusCode : (err ? err.statusCode : null) return { statusCode } } render () { const { statusCode } = this.props const title = statusCode === 404 ? 'This page could not be found' : HTTPStatus[statusCode] || 'An unexpected error has occurred' return
{statusCode}: {title}