import * as Sentry from '@sentry/react'; import { Splash } from '@vegaprotocol/ui-toolkit'; import React from 'react'; import type { WithTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next'; import { Route, Routes } from 'react-router-dom'; import { SplashLoader } from '../components/splash-loader'; import routerConfig from './router-config'; export interface RouteChildProps { name: string; } interface RouteErrorBoundaryProps extends WithTranslation { children: React.ReactElement; } class RouteErrorBoundary extends React.Component< RouteErrorBoundaryProps, { hasError: boolean } > { constructor(props: RouteErrorBoundaryProps) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError() { return { hasError: true }; } override componentDidCatch(error: Error) { Sentry.captureException(error); } override render() { if (this.state.hasError) { return

{this.props.t('Something went wrong')}

; } return this.props.children; } } const BoundaryWithTranslation = withTranslation()(RouteErrorBoundary); export const AppRouter = () => { const splashLoading = ( ); return ( // @ts-ignore withTranslation HOC types not working {routerConfig.map( ({ path, component: Component, name, children }) => ( }> {children && children.length ? children.map((child) => ( )) : null} ) )} ); };