2021-02-04 19:15:23 +01:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
import { HashRouter } from 'react-router-dom';
|
|
|
|
import * as Sentry from '@sentry/browser';
|
|
|
|
import { I18nProvider, LegacyI18nProvider } from '../contexts/i18n';
|
2020-09-14 19:04:05 +02:00
|
|
|
import {
|
2022-04-01 21:11:12 +02:00
|
|
|
MetaMetricsProvider,
|
|
|
|
LegacyMetaMetricsProvider,
|
|
|
|
} from '../contexts/metametrics';
|
2021-02-04 19:15:23 +01:00
|
|
|
import ErrorPage from './error';
|
|
|
|
import Routes from './routes';
|
2019-03-22 00:03:30 +01:00
|
|
|
|
2020-01-24 22:11:02 +01:00
|
|
|
class Index extends PureComponent {
|
2021-02-04 19:15:23 +01:00
|
|
|
state = {};
|
2019-03-22 00:03:30 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
static getDerivedStateFromError(error) {
|
2021-02-04 19:15:23 +01:00
|
|
|
return { error };
|
2020-01-24 22:11:02 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
componentDidCatch(error) {
|
2021-02-04 19:15:23 +01:00
|
|
|
Sentry.captureException(error);
|
2020-01-24 22:11:02 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { error, errorId } = this.state;
|
|
|
|
const { store } = this.props;
|
2020-01-24 22:11:02 +01:00
|
|
|
|
|
|
|
if (error) {
|
|
|
|
return (
|
|
|
|
<Provider store={store}>
|
2019-12-06 16:40:07 +01:00
|
|
|
<I18nProvider>
|
2020-03-23 18:07:05 +01:00
|
|
|
<LegacyI18nProvider>
|
2020-11-03 00:41:28 +01:00
|
|
|
<ErrorPage error={error} errorId={errorId} />
|
2020-03-23 18:07:05 +01:00
|
|
|
</LegacyI18nProvider>
|
2019-12-06 16:40:07 +01:00
|
|
|
</I18nProvider>
|
2020-01-24 22:11:02 +01:00
|
|
|
</Provider>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-01-24 22:11:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Provider store={store}>
|
|
|
|
<HashRouter hashType="noslash">
|
2022-04-01 21:11:12 +02:00
|
|
|
<MetaMetricsProvider>
|
|
|
|
<LegacyMetaMetricsProvider>
|
2022-03-31 19:10:19 +02:00
|
|
|
<I18nProvider>
|
|
|
|
<LegacyI18nProvider>
|
|
|
|
<Routes />
|
|
|
|
</LegacyI18nProvider>
|
|
|
|
</I18nProvider>
|
2022-04-01 21:11:12 +02:00
|
|
|
</LegacyMetaMetricsProvider>
|
|
|
|
</MetaMetricsProvider>
|
2020-01-24 22:11:02 +01:00
|
|
|
</HashRouter>
|
|
|
|
</Provider>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-01-24 22:11:02 +01:00
|
|
|
}
|
2019-03-22 00:03:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Index.propTypes = {
|
|
|
|
store: PropTypes.object,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-03-22 00:03:30 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
export default Index;
|