-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
51 lines (45 loc) · 1.18 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
import 'react-native-gesture-handler';
import './src/api';
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 { App } from './src/App';
import { name as appName } from './app.json';
LogBox.ignoreLogs(['Require cycle:', 'new NativeEventEmitter()', "Can't perform"]);
enableFreeze();
/**
* 未捕获的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);