rasengan
Version:
The modern React Framework
43 lines (42 loc) • 1.5 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { Component } from 'react';
import { errorStore } from './error-store.js';
export class ErrorBoundaryFallback extends Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError() {
return { hasError: true };
}
componentDidCatch(error, info) {
errorStore.addError(error, 'react', info.componentStack);
}
render() {
if (this.state.hasError) {
if (typeof process !== 'undefined' &&
process.env?.NODE_ENV === 'production') {
return (_jsx("section", { style: {
position: 'fixed',
top: 0,
left: 0,
right: 0,
bottom: 0,
zIndex: 100,
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
height: '100vh',
width: '100vw',
gap: 10,
backgroundColor: '#fff',
}, children: _jsx("p", { style: {
fontSize: '18px',
}, children: "Application Error" }) }));
}
return null;
}
return this.props.children;
}
}