guild_front/src/hoc/ErrorBoundary.js
2023-05-31 08:36:15 +03:00

23 lines
399 B
JavaScript

import React, { Component } from "react";
class ErrorBoundary extends Component {
state = {
error: null,
};
static getDerivedStateFromError(error) {
return { error };
}
render() {
const { error } = this.state;
if (error) {
return <div>Что-то пошло не так =( {error}</div>;
}
return this.props.children;
}
}
export default ErrorBoundary;