UNPKG

@commercelayer/react-components

Version:
2 lines 650 B
"use client"; "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ErrorBoundary=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react");class ErrorBoundary extends react_1.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(error,errorInfo){if(process.env.NODE_ENV!=="test")console.error("Uncaught error:",error,errorInfo);else throw error}render(){return this.state.hasError?(0,jsx_runtime_1.jsx)("h1",{children:"Sorry.. there was an error, check the console."}):this.props.children}}exports.ErrorBoundary=ErrorBoundary,exports.default=ErrorBoundary;