import { ReactNode , Component } from "react" ; function muteConsoleErrors ( patterns ) { const nativeConsoleError = console . error . bind ( console ) ; console . error = message => { if ( ! patterns . some ( x => message . includes ( x ) ) ) { nativeConsoleError ( message ) ; } } ; return ( ) => { console . error = nativeConsoleError ; } ; } interface ErrorBoundaryProps { onError : ( error : Error ) => void ; children ? : ReactNode ; } class ErrorBoundary extends Component < ErrorBoundaryProps , { hasError : boolean ; } > { constructor ( props ) { super ( props ) ; this . state = { hasError : false } ; } componentDidCatch ( error ) { const { onError } = this . props ; onError ( error ) ; } static getDerivedStateFromError ( ) { return { hasError : true } ; } render ( ) { if ( this . state . hasError ) { return null ; } const { children } = this . props ; return children ; } } export { muteConsoleErrors , ErrorBoundary } ;