-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
52 lines (46 loc) · 1.37 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
import { Alert, AppRegistry, LogBox } from 'react-native';
import { setJSExceptionHandler, setNativeExceptionHandler } from 'react-native-exception-handler';
import RNRestart from 'react-native-restart';
import { enableFreeze } from 'react-native-screens';
import { PullToRefresh } from '@sdcx/pull-to-refresh'
import { App } from './src/App';
import { name as appName } from './app.json';
import CustomPullRefreshHeader from './src/components/CustomPullRefreshHeader';
LogBox.ignoreLogs(['Require cycle:', 'new NativeEventEmitter()', "Can't perform", "Flipper", "RCTBridge", "Non-serializable values were found"]);
enableFreeze();
PullToRefresh.setDefaultHeader(CustomPullRefreshHeader)
/**
* 未捕获的JS异常
*/
setJSExceptionHandler((error, isFatal) => {
if (isFatal) {
Alert.alert(
'未知异常',
`
Error: ${isFatal ? 'Fatal:' : ''} ${error.name} ${error.message}
APP需要被重启
`,
[
{
text: '重启',
onPress: () => {
RNRestart.Restart();
},
},
],
);
} else {
console.log(error); // So that we can see it in the ADB logs in case of Android if needed
}
}, false);
/**
* 未捕获的原生异常
*/
setNativeExceptionHandler(
exceptionString => {
console.log(exceptionString);
},
false,
true,
);
AppRegistry.registerComponent(appName, () => App);