UNPKG

@jbrowse/core

Version:

JBrowse 2 core libraries used by plugins

20 lines (19 loc) 701 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ErrorBoundary = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = require("react"); class ErrorBoundary extends react_1.Component { constructor(props) { super(props); this.state = { error: undefined }; } componentDidCatch(error, errorInfo) { console.error('ErrorBoundary caught an error:', error, errorInfo); this.setState({ error }); } render() { return this.state.error ? ((0, jsx_runtime_1.jsx)(this.props.FallbackComponent, { error: this.state.error })) : (this.props.children); } } exports.ErrorBoundary = ErrorBoundary;