import { Component } from '@wordpress/element'; import type { ErrorInfo, ReactNode } from 'react'; import { __ } from '@wordpress/i18n'; interface Props { children: ReactNode; } interface State { hasError: boolean; error?: Error; } class ErrorBoundary extends Component { public state: State = { hasError: false }; public static getDerivedStateFromError(error: Error): State { return { hasError: true, error }; } public componentDidCatch(error: Error, errorInfo: ErrorInfo) { console.error('Uncaught error:', error, errorInfo); } public render() { if (this.state.hasError) { return (

{__('Something went wrong', 'burst-statistics')}

{__('Please try refreshing the page or contact support if the problem persists.', 'burst-statistics')}

); } return this.props.children; } } export { ErrorBoundary };