-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.android.js
37 lines (30 loc) · 1.01 KB
/
index.android.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
import {Provider} from 'react-redux';
import store from './src/redux/store';
import AppViewContainer from './src/modules/AppViewContainer';
import React, {Component} from 'react';
import {AppRegistry, BackHandler} from 'react-native';
import {NavigationActions} from 'react-navigation';
class Hangboard extends Component {
componentWillMount() {
BackHandler.addEventListener('hardwareBackPress', this.navigateBack);
}
navigateBack() {
const navigatorState = store.getState().get('navigatorState');
const currentStackScreen = navigatorState.get('index');
const currentTab = navigatorState.getIn(['routes', 0, 'index']);
if (currentTab !== 0 || currentStackScreen !== 0) {
store.dispatch(NavigationActions.back());
return true;
}
// otherwise let OS handle the back button action
return false;
}
render() {
return (
<Provider store={store}>
<AppViewContainer />
</Provider>
);
}
}
AppRegistry.registerComponent('Hangboard', () => Hangboard);