You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
466 B
JavaScript

import React from 'react'
import ErrorPage from '~/pages/_error'
export default class ErrorBoundary extends React.Component {
constructor(props) {
super()
this.state = {error: null};
}
static getDerivedStateFromError(error){
return {error: error || {name: 'Not found', message: 'This page could not be found'}}
}
render() {
if(this.state.error)
return <ErrorPage error={this.state.error} />
return this.props.children;
}
}