import { __ } from '@wordpress/i18n'; import React from 'react'; import { Alert, Button } from './index.jsx'; export default class AppErrorBoundary extends React.Component { constructor( props ) { super( props ); this.state = { hasError: false, errorMessage: '', }; } static getDerivedStateFromError( error ) { return { hasError: true, errorMessage: error?.message || 'Unknown error', }; } componentDidCatch( error ) { if ( window?.arrayfunnelAdmin ) { window.arrayfunnelAdmin.lastError = String( error?.message || '' ); } } handleRecover = () => { this.setState( { hasError: false, errorMessage: '', } ); if ( typeof window !== 'undefined' ) { window.location.hash = '#/'; } }; render() { if ( ! this.state.hasError ) { return this.props.children; } return (
{ __( 'A rendering error occurred on this admin route. You can return to Home and retry.', 'arrayfunnel' ) }