UNPKG

@airplane/views

Version:

A React library for building Airplane views. Views components are optimized in style and functionality to produce internal apps that are easy to build and maintain.

42 lines (41 loc) 1.12 kB
import { jsx } from "react/jsx-runtime"; import { uniqueId } from "lodash-es"; import hash from "object-hash"; import { Component } from "react"; import { sendViewMessage } from "../../message/sendViewMessage.js"; import { ErrorFallback } from "./ErrorFallback.js"; class ErrorBoundary extends Component { constructor(props) { super(props); this.state = {}; } componentDidCatch(error, errorInfo) { const errorID = uniqueId(); this.setState({ error, errorInfo, errorID }); sendViewMessage({ type: "console", id: errorID, messageType: "error", message: error.message, hash: hash(error), time: Date.now() }); } render() { if (this.state.error && this.state.errorInfo && this.state.errorID) { if (this.props.fallback) { return this.props.fallback; } return /* @__PURE__ */ jsx(ErrorFallback, { errorID: this.state.errorID, error: this.state.error, errorInfo: this.state.errorInfo }); } return this.props.children; } } export { ErrorBoundary }; //# sourceMappingURL=ErrorBoundary.js.map