@thisismanta/react-playbook
Version:
**Playbook** is a UI library made for listing React components.
31 lines (30 loc) • 1.02 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"));
class ErrorBoundary extends react_1.default.PureComponent {
constructor(props) {
super(props);
this.state = {};
}
static getDerivedStateFromError(error) {
return { error };
}
render() {
if (this.state.error) {
return (react_1.default.createElement("div", { style: {
display: 'inline-block',
background: 'red',
color: 'white',
padding: '10px',
fontFamily: 'var(--font-family)',
fontWeight: 400,
fontSize: '14px'
} }, String(this.state.error)));
}
return this.props.children;
}
}
exports.default = ErrorBoundary;