UNPKG

@turbox3d/reactivity-react

Version:

Large-scale reactive state management library for react

42 lines 1.75 kB
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; import _createClass from "@babel/runtime/helpers/esm/createClass"; import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf"; import _inherits from "@babel/runtime/helpers/esm/inherits"; function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } import * as React from 'react'; var ErrorBoundary = /*#__PURE__*/function (_React$Component) { function ErrorBoundary() { var _this; _classCallCheck(this, ErrorBoundary); _this = _callSuper(this, ErrorBoundary, arguments); _this.state = { hasError: false, error: { message: '' } }; return _this; } _inherits(ErrorBoundary, _React$Component); return _createClass(ErrorBoundary, [{ key: "componentDidCatch", value: function componentDidCatch(error) { this.setState({ hasError: true, error: error }); } }, { key: "render", value: function render() { var message = this.state.error.message; if (this.state.hasError) { return React.createElement("h2", null, "Something went wrong. Error: ", message); } return this.props.children; } }]); }(React.Component); export { ErrorBoundary as default };