burdy
Version:
Open Source Headless Platform
31 lines (30 loc) • 1.11 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
const react_2 = require("@fluentui/react");
;
class ErrorBoundary extends react_1.default.Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError() {
// Update state so the next render will show the fallback UI.
return { hasError: true };
}
componentDidCatch(error, errorInfo) {
console.error(errorInfo);
}
render() {
var _a;
// @ts-ignore
if (this.state.hasError) {
return react_1.default.createElement(react_2.MessageBar, { messageBarType: react_2.MessageBarType.error }, ((_a = this.props) === null || _a === void 0 ? void 0 : _a.message) || 'Error!, please check console for more details.');
}
return this.props.children;
}
}
exports.default = ErrorBoundary;