@commercelayer/react-components
Version:
The Official Commerce Layer React Components
2 lines • 689 B
JavaScript
"use client";
;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{constructor(){super(...arguments),this.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;