dyno-bot/Dyno-web-premium-before-reset/react/dashboard/common/ErrorHandler.jsx
2020-09-12 19:08:48 +01:00

27 lines
816 B
JavaScript

import React from 'react';
export default class ErrorHandler extends React.Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
componentDidCatch(error, info) {
this.setState({ hasError: true });
}
render() {
if (this.state.hasError) {
// You can render any custom fallback UI
return (
<div className='react-error-wrapper'>
<i className="fas fa-times-circle fa-6x"></i>
<h1>Oops. Something went wrong</h1>
<h3>Please try again. If the error persists, let us know in our <a href='https://discordapp.com/invite/dyno'>support server</a></h3>
</div>
);
}
return this.props.children;
}
}