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

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