UNPKG

@tomino/dynamic-form-semantic-ui

Version:

Semantic UI form renderer based on dynamic form generation

36 lines 1.27 kB
import * as React from 'react'; import { Segment } from 'semantic-ui-react'; import { css } from '../common'; const segment = css ` margin: 12px !important; `; const error = css ` overflow: auto; `; export 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(Segment, { inverted: true, attached: "top", color: "red" }, "\uD83D\uDE22 ", this.state.error.message), React.createElement(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'; //# sourceMappingURL=error_boundary.js.map