@kwiz/fluentui
Version:
KWIZ common controls for FluentUI
33 lines • 1.19 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import * as React from "react";
import { GetLogger } from "../_modules/config";
const logger = GetLogger("ErrorBoundary");
export class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { hasError: false, marker: props.changeMarker };
}
static getDerivedStateFromError(error) {
// Update state so the next render will show the fallback UI.
return { hasError: true };
}
static getDerivedStateFromProps(props, state) {
if (props.changeMarker !== state.marker)
return { hasError: false, marker: props.changeMarker };
else
return null;
}
componentDidCatch(error, errorInfo) {
// You can also log the error to an error reporting service
logger.error(error);
logger.error(errorInfo);
}
render() {
if (this.state.hasError) {
// You can render any custom fallback UI
return this.props.errorComponent || _jsx("h1", { children: "Something went wrong." });
}
return this.props.children;
}
}
//# sourceMappingURL=error-boundary.js.map