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-11-03 00:41:28 +01:00
|
|
|
import {
|
|
|
|
MetaMetricsProvider,
|
|
|
|
LegacyMetaMetricsProvider,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../contexts/metametrics';
|
2020-09-14 19:04:05 +02:00
|
|
|
import {
|
|
|
|
MetaMetricsProvider as NewMetaMetricsProvider,
|
|
|
|
LegacyMetaMetricsProvider as NewLegacyMetaMetricsProvider,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../contexts/metametrics.new';
|
|
|
|
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">
|
|
|
|
<MetaMetricsProvider>
|
2020-05-08 18:41:43 +02:00
|
|
|
<LegacyMetaMetricsProvider>
|
2020-09-14 19:04:05 +02:00
|
|
|
<NewMetaMetricsProvider>
|
|
|
|
<NewLegacyMetaMetricsProvider>
|
|
|
|
<I18nProvider>
|
|
|
|
<LegacyI18nProvider>
|
|
|
|
<Routes />
|
|
|
|
</LegacyI18nProvider>
|
|
|
|
</I18nProvider>
|
|
|
|
</NewLegacyMetaMetricsProvider>
|
|
|
|
</NewMetaMetricsProvider>
|
2020-05-08 18:41:43 +02:00
|
|
|
</LegacyMetaMetricsProvider>
|
2020-01-24 22:11:02 +01:00
|
|
|
</MetaMetricsProvider>
|
|
|
|
</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;
|