-
Notifications
You must be signed in to change notification settings - Fork 36
/
index.js
62 lines (54 loc) · 1.72 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
import { Alert, AppRegistry, LogBox } from 'react-native';
import { Animated, TextInput } 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 { Text } from '@td-design/react-native';
import { name as appName } from './app.json';
import { App } from './src/App';
import CustomPullRefreshHeader from './src/components/CustomPullRefreshHeader';
enableFreeze();
PullToRefresh.setDefaultHeader(CustomPullRefreshHeader);
/** 如果你不想要让App的字体跟随系统字体,就需要下面这段代码 */
if (!Animated.Text.defaultProps) Animated.Text.defaultProps = {};
if (!Text.defaultProps) Text.defaultProps = {};
if (!TextInput.defaultProps) TextInput.defaultProps = {};
Animated.Text.defaultProps.allowFontScaling = false;
Text.defaultProps.allowFontScaling = false;
TextInput.defaultProps.allowFontScaling = false;
/**
* 未捕获的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);