forked from bitpay/bitpay-app
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
81 lines (75 loc) · 2.25 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import 'react-native-get-random-values'; // must import before @ethersproject/shims
import '@ethersproject/shims';
import './shim';
import '@walletconnect/react-native-compat';
import {AppRegistry, Alert} from 'react-native';
import Root from './src/Root';
import React from 'react';
import './i18n';
import {
setJSExceptionHandler,
setNativeExceptionHandler,
} from 'react-native-exception-handler';
import {name as appName} from './app.json';
import getStore from './src/store';
import {Provider} from 'react-redux';
import {PersistGate} from 'redux-persist/integration/react';
import 'react-native-url-polyfill/auto'; // https://github.com/facebook/react-native/issues/23922#issuecomment-648096619
import {enableFreeze} from 'react-native-screens';
import {AppInitialization} from './src/AppInitialization';
import {Analytics} from './src/store/analytics/analytics.effects';
import {APP_VERSION} from './src/constants/config';
import {GIT_COMMIT_HASH} from '@env';
import {LogActions} from './src/store/log';
enableFreeze(true);
const {store, persistor} = getStore();
const errorHandler = (e, isFatal) => {
if (isFatal) {
store.dispatch(
Analytics.track('BitPay App - Crashed App', {
build: GIT_COMMIT_HASH,
version: APP_VERSION,
}),
);
const errStr = e instanceof Error ? e.message : JSON.stringify(e);
store.dispatch(LogActions.persistLog(LogActions.error(errStr)));
Alert.alert(
'Unexpected error occurred',
`
Error: ${errStr}
`,
[
{
text: 'Close',
},
],
);
}
};
const exceptionHandler = () => {
store.dispatch(
Analytics.track('BitPay App - Crashed App', {
build: GIT_COMMIT_HASH,
version: APP_VERSION,
}),
);
};
// Handle uncaught exceptions
setJSExceptionHandler(errorHandler, true);
setNativeExceptionHandler(exceptionHandler);
const ReduxProvider = () => {
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
{storeRehydrated =>
storeRehydrated ? (
<AppInitialization>
<Root />
</AppInitialization>
) : null
}
</PersistGate>
</Provider>
);
};
AppRegistry.registerComponent(appName, () => ReduxProvider);