import { useEffect, VFC } from 'react'; import { useNavigate } from 'react-router-dom'; import { Box } from '@mui/material'; import { Dialogue } from 'component/common/Dialogue/Dialogue'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { usePlausibleTracker } from 'hooks/usePlausibleTracker'; interface IErrorProps { error: Error; } export const Error: VFC = ({ error }) => { const navigate = useNavigate(); const { trackEvent } = usePlausibleTracker(); useEffect(() => { const { message, stack = 'unknown' } = error; trackEvent('unknown_ui_error', { props: { location: window?.location?.href || 'unknown', message, stack, }, }); }, []); return ( { navigate('/'); window?.location?.reload(); }} secondaryButtonText="Reload this page" onClose={() => { window?.location?.reload(); }} maxWidth="xl" > {error.message} {error.stack} } /> ); };