import { __ } from '@wordpress/i18n'; import { SnackbarList, Button } from '@wordpress/components'; import { useState, useEffect, useCallback, createContext, useContext, Component, } from '@wordpress/element'; import { useRoute } from './router'; import { config } from './api'; import { I } from './ui'; import { getPage, onPagesChange } from './registry'; import './pages'; export type Notify = ( content: string, status?: string ) => void; const NoticeContext = createContext< Notify >( () => {} ); export const useNotice = () => useContext( NoticeContext ); /** Keeps one broken screen from taking the whole admin down. */ class ErrorBoundary extends Component< { resetKey: string; children?: React.ReactNode }, { error: any } > { constructor( props ) { super( props ); this.state = { error: null }; } static getDerivedStateFromError( error ) { return { error }; } componentDidUpdate( prev ) { if ( prev.resetKey !== this.props.resetKey && this.state.error ) { this.setState( { error: null } ); } } render() { if ( this.state.error ) { return (
{ __( 'Your data is safe. Reload the page; if it keeps happening, send us the message below.', 'streamsera' ) }
{ String(
this.state.error?.message || this.state.error
) }