import React from 'react'; import { ErrorBoundary as ReactErrorBoundary } from 'react-error-boundary'; import PropTypes from 'prop-types'; import './ErrorFallback.css'; const isProduction = process.env.NODE_ENV === 'production'; const ErrorFallback = ({ error, componentStack, resetErrorBoundary }) => { return (

Something went wrong.

{isProduction && ( Sorry, something went wrong there. Try again. )} {!isProduction &&
{error.message}
} {!isProduction &&
{componentStack}
}
); }; ErrorFallback.propTypes = { resetErrorBoundary: PropTypes }; const ErrorBoundary = ({ context = 'RCT', onReset = () => { }, onError = () => { }, fallbackComponent, children }) => { const onErrorHandler = (error, componentStack) => { console.error(`${context} Error Boundary`, error, componentStack); onError(error, componentStack); }; const onResetHandler = () => { onReset(); }; return ( {children} ); }; export default ErrorBoundary;