@tomino/dynamic-form-semantic-ui
Version:
Semantic UI form renderer based on dynamic form generation
40 lines • 1.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const semantic_ui_react_1 = require("semantic-ui-react");
const common_1 = require("../common");
const segment = common_1.css `
margin: 12px !important;
`;
const error = common_1.css `
overflow: auto;
`;
class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
componentDidCatch(error, info) {
this.setState({ hasError: true, error, info });
console.group('REACT ERROR');
console.error(error);
console.error(info);
console.groupEnd();
}
render() {
if (this.state.hasError) {
return (React.createElement("div", { className: segment },
React.createElement(semantic_ui_react_1.Segment, { inverted: true, attached: "top", color: "red" },
"\uD83D\uDE22 ",
this.state.error.message),
React.createElement(semantic_ui_react_1.Segment, { attached: "bottom", className: error },
React.createElement("pre", null, this.state.error.stack),
React.createElement("pre", null, this.state.info.componentStack))));
}
return this.props.children;
}
}
ErrorBoundary.displayName = 'ErrorBoundary';
exports.ErrorBoundary = ErrorBoundary;
//# sourceMappingURL=error_boundary.js.map