mirror of https://gitlab.com/ecentrics/concordia
Ezerous
4 years ago
2 changed files with 28 additions and 3 deletions
@ -0,0 +1,22 @@ |
|||||
|
import React from 'react'; |
||||
|
|
||||
|
class ErrorBoundary extends React.Component { |
||||
|
constructor(props) { |
||||
|
super(props); |
||||
|
this.state = { hasError: false }; |
||||
|
} |
||||
|
|
||||
|
static getDerivedStateFromError() { |
||||
|
return { hasError: true }; |
||||
|
} |
||||
|
|
||||
|
render() { |
||||
|
const { props: { children }, state: { hasError } } = this; |
||||
|
if (hasError) { |
||||
|
return <h1>Something went wrong.</h1>; // TODO: Make a better "Something went wrong" screen |
||||
|
} |
||||
|
return children; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export default ErrorBoundary; |
Loading…
Reference in new issue