ecency-mobile/src/index.js

47 lines
1.4 KiB
JavaScript
Raw Normal View History

import React from 'react';
2019-07-18 11:10:34 +03:00
import { Provider, connect } from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react';
import { IntlProvider, addLocaleData } from 'react-intl';
import en from 'react-intl/locale-data/en';
import id from 'react-intl/locale-data/id';
import ru from 'react-intl/locale-data/ru';
import de from 'react-intl/locale-data/de';
import it from 'react-intl/locale-data/it';
import hu from 'react-intl/locale-data/hu';
import tr from 'react-intl/locale-data/tr';
import ko from 'react-intl/locale-data/ko';
import lt from 'react-intl/locale-data/lt';
import pt from 'react-intl/locale-data/pt';
import fa from 'react-intl/locale-data/fa';
2019-07-18 11:10:34 +03:00
import { flattenMessages } from './utils/flattenMessages';
import messages from './config/locales';
import Application from './screens/application';
import { store, persistor } from './redux/store/store';
2018-11-14 17:29:29 +03:00
addLocaleData([...en, ...ru, ...de, ...id, ...it, ...hu, ...tr, ...ko, ...pt, ...lt, ...fa]);
2019-07-18 11:10:34 +03:00
const _renderApp = ({ locale }) => (
<PersistGate loading={null} persistor={persistor}>
<IntlProvider locale={locale} messages={flattenMessages(messages[locale])}>
<Application />
2019-07-18 11:10:34 +03:00
</IntlProvider>
</PersistGate>
);
2019-07-18 11:10:34 +03:00
const mapStateToProps = state => ({
locale: state.application.language,
});
const App = connect(mapStateToProps)(_renderApp);
export default () => {
return (
<Provider store={store}>
<App />
</Provider>
);
};