import { Component, ErrorInfo, ReactNode } from "react"; import { scope } from "../utils/sentry"; interface Props { children: ReactNode; } interface State { hasError: boolean; } class ErrorBoundary extends Component { constructor(props: Props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(): State { return { hasError: true }; } componentDidCatch(error: Error, errorInfo: ErrorInfo) { scope.captureException(error, { captureContext: { extra: { componentStack: errorInfo.componentStack } } }); } render() { if (this.state.hasError) { return null; } return this.props.children; } } export default ErrorBoundary;