From 9fb648d6e9ef7c0e80c1c3c085d07f377d8b1d0c Mon Sep 17 00:00:00 2001 From: SHAES Farm <60716043+shaes-farm@users.noreply.github.com> Date: Sat, 2 Sep 2023 06:06:17 -0400 Subject: [PATCH] Remove ErrorBoundary component --- src/components/Auth/AuthShell.tsx | 5 +- src/components/ErrorBoundary.tsx | 43 ------------- .../__tests__/ErrorBoundary.test.tsx | 60 ------------------- 3 files changed, 2 insertions(+), 106 deletions(-) delete mode 100644 src/components/ErrorBoundary.tsx delete mode 100644 src/components/__tests__/ErrorBoundary.test.tsx diff --git a/src/components/Auth/AuthShell.tsx b/src/components/Auth/AuthShell.tsx index 5d06119..5b6285b 100644 --- a/src/components/Auth/AuthShell.tsx +++ b/src/components/Auth/AuthShell.tsx @@ -5,7 +5,6 @@ import Paper from '@mui/material/Paper'; import type {AppConfig} from '../App'; import Copyright from '../Copyright'; -import ErrorBoundary from '../ErrorBoundary'; import {Auth} from './Auth'; import type { @@ -34,7 +33,7 @@ export const AuthShell: React.FC = ({config, signIn, signUp, rec }, [view]); return ( - + <> = ({config, signIn, signUp, rec - + ); }; diff --git a/src/components/ErrorBoundary.tsx b/src/components/ErrorBoundary.tsx deleted file mode 100644 index 6d50bc2..0000000 --- a/src/components/ErrorBoundary.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import React from 'react'; - -import {SnackBarAlert} from './SnackBarAlert'; - -export interface ErrorBoundaryProps { - children: React.ReactNode; -} - -export interface ErrorBoundaryState { - errorMsg: string; -} - -export class ErrorBoundary extends React.Component { - state: ErrorBoundaryState = { - errorMsg: '' - }; - - constructor(props: never) { - super(props); - } - - componentDidCatch(error: Error) { - this.setState({errorMsg: `${error.name}: ${error.message}`}); - } - - render() { - const {errorMsg} = this.state; - const {children} = this.props; - - if (errorMsg) { - return ( - <> - {children} - this.setState({errorMsg: ''})} /> - - ); - } - - return <>{children}; - } -} - -export default ErrorBoundary; diff --git a/src/components/__tests__/ErrorBoundary.test.tsx b/src/components/__tests__/ErrorBoundary.test.tsx deleted file mode 100644 index b1ecc4e..0000000 --- a/src/components/__tests__/ErrorBoundary.test.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import React from 'react'; -import {cleanup, render} from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; -import {Button} from '@mui/material'; - -import ErrorBoundary from '../ErrorBoundary'; - -const MockSnackBarAlert = () => { - return ; -}; - -jest.mock('../SnackBarAlert', () => MockSnackBarAlert); - -const user = userEvent.setup(); - -const ErrorComponent = () => { - return