-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (34 loc) · 1.05 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
// import { NativeModules } from 'react-native';
// const { HCTInstanceloader } = NativeModules;
// export default HCTInstanceloader;
import React from 'react';
import { DeviceEventEmitter, Alert } from 'react-native';
class NavigationHelperComp extends React.Component {
componentWillMount() {
DeviceEventEmitter.addListener('RNInstanceFinished', this.onNavigate);
DeviceEventEmitter.addListener('RNInstanceFailed', this.onFailed);
}
componentWillUnmount() {
DeviceEventEmitter.removeListener('RNInstanceFinished', this.onNavigate);
DeviceEventEmitter.removeListener('RNInstanceFailed', this.onFailed);
}
onNavigate = (navParams) => {
const {
navigation: {
routeName,
params,
action,
} = {},
} = navParams;
if (routeName) {
this.props.navigation.navigate(routeName, params, action);
}
}
onFailed = (msg) => {
Alert.alert('异常退出', `${msg['PARAMS_MODULE_NAME']}发生了异常...`);
}
render() {
return null;
}
}
export default NavigationHelperComp;