From f418231b6b2f5e030a0d2dcc390c314602b1f740 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 6 Apr 2024 09:22:10 -0700 Subject: Move modern to the top --- src/ErrorBoundary.jsx | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/ErrorBoundary.jsx (limited to 'src/ErrorBoundary.jsx') diff --git a/src/ErrorBoundary.jsx b/src/ErrorBoundary.jsx new file mode 100644 index 00000000..93a6fe0f --- /dev/null +++ b/src/ErrorBoundary.jsx @@ -0,0 +1,35 @@ +import React from 'react'; +import { Alert } from '@mui/material'; + +class ErrorBoundary extends React.Component { + constructor(props) { + super(props); + this.state = { + error: null, + }; + } + + static getDerivedStateFromError(error) { + return { error }; + } + + /* eslint-disable react/no-danger */ + render() { + const { error } = this.state; + if (error) { + return ( + + ').replaceAll(' ', ' '), + }} + /> + + ); + } + const { children } = this.props; + return children; + } +} + +export default ErrorBoundary; -- cgit v1.2.3