1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-05 07:24:56 +01:00
metamask-extension/ui/pages/index.js

64 lines
1.5 KiB
JavaScript
Raw Normal View History

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';
import {
MetaMetricsProvider,
LegacyMetaMetricsProvider,
} from '../contexts/metametrics';
import ErrorPage from './error';
import Routes from './routes';
class Index extends PureComponent {
state = {};
2020-11-03 00:41:28 +01:00
static getDerivedStateFromError(error) {
return { error };
}
2020-11-03 00:41:28 +01:00
componentDidCatch(error) {
Sentry.captureException(error);
}
2020-11-03 00:41:28 +01:00
render() {
const { error, errorId } = this.state;
const { store } = this.props;
if (error) {
return (
<Provider store={store}>
<I18nProvider>
<LegacyI18nProvider>
2020-11-03 00:41:28 +01:00
<ErrorPage error={error} errorId={errorId} />
</LegacyI18nProvider>
</I18nProvider>
</Provider>
);
}
return (
<Provider store={store}>
<HashRouter hashType="noslash">
<MetaMetricsProvider>
<LegacyMetaMetricsProvider>
<I18nProvider>
<LegacyI18nProvider>
<Routes />
</LegacyI18nProvider>
</I18nProvider>
</LegacyMetaMetricsProvider>
</MetaMetricsProvider>
</HashRouter>
</Provider>
);
}
}
Index.propTypes = {
store: PropTypes.object,
};
export default Index;