mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-27 21:00:13 +01:00
2b6aff535e
The "i18n-provider" module has been replaced by a new `i18n.js` module in the `contexts` directory which provides the `t` function via the new React Context API. The legacy context API is still used throughout the codebase, so a legacy context provider has also been added as a shim until we migrate away from the old API. The migration does require changing every single place where the `t` function is used, so it is a non-trivial amount of work. This shim allows us to tackle it one piece at a time without breaking anything. This was placed in a new `contexts` directory because it didn't seem to belong in any existing categories. It certainly isn't a higher-order component.
62 lines
1.4 KiB
JavaScript
62 lines
1.4 KiB
JavaScript
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 ErrorPage from './error'
|
|
import Routes from './routes'
|
|
import { I18nProvider, LegacyI18nProvider } from '../contexts/i18n'
|
|
import MetaMetricsProvider from '../helpers/higher-order-components/metametrics/metametrics.provider'
|
|
|
|
class Index extends PureComponent {
|
|
state = {}
|
|
|
|
static getDerivedStateFromError (error) {
|
|
return { error }
|
|
}
|
|
|
|
componentDidCatch (error) {
|
|
Sentry.captureException(error)
|
|
}
|
|
|
|
render () {
|
|
const { error, errorId } = this.state
|
|
const { store } = this.props
|
|
|
|
if (error) {
|
|
return (
|
|
<Provider store={store}>
|
|
<I18nProvider>
|
|
<LegacyI18nProvider>
|
|
<ErrorPage
|
|
error={error}
|
|
errorId={errorId}
|
|
/>
|
|
</LegacyI18nProvider>
|
|
</I18nProvider>
|
|
</Provider>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<Provider store={store}>
|
|
<HashRouter hashType="noslash">
|
|
<MetaMetricsProvider>
|
|
<I18nProvider>
|
|
<LegacyI18nProvider>
|
|
<Routes />
|
|
</LegacyI18nProvider>
|
|
</I18nProvider>
|
|
</MetaMetricsProvider>
|
|
</HashRouter>
|
|
</Provider>
|
|
)
|
|
}
|
|
}
|
|
|
|
Index.propTypes = {
|
|
store: PropTypes.object,
|
|
}
|
|
|
|
export default Index
|