ecency-mobile/src/index.js

41 lines
1.0 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';
2019-08-12 11:10:52 +03:00
import { IntlProvider } from 'react-intl';
2019-10-04 18:56:22 +03:00
import { useScreens } from 'react-native-screens';
import { setTopLevelNavigator } from './navigation/service';
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
2019-10-04 18:56:22 +03:00
useScreens();
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
ref={navigatorRef => {
setTopLevelNavigator(navigatorRef);
}}
/>
2019-07-18 11:10:34 +03:00
</Provider>
);
};