Merge pull request #229 from esteemapp/bugfix/android-back-button

Fixed #189
This commit is contained in:
Feruz M 2018-12-12 15:34:46 +02:00 committed by GitHub
commit de86f45640
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,10 @@
import React, { Component } from 'react';
import { Platform } from 'react-native';
import { Platform, BackHandler } from 'react-native';
import { connect } from 'react-redux';
import { addLocaleData } from 'react-intl';
import Config from 'react-native-config';
import AppCenter from 'appcenter';
import { NavigationActions } from 'react-navigation';
// Constants
import en from 'react-intl/locale-data/en';
@ -54,6 +55,7 @@ class ApplicationContainer extends Component {
}
componentDidMount = async () => {
BackHandler.addEventListener('hardwareBackPress', this._onBackPress);
await this._getUserData();
this._getSettings();
};
@ -66,6 +68,17 @@ class ApplicationContainer extends Component {
}
}
componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.onBackPress);
}
_onBackPress = () => {
const { dispatch } = this.props;
dispatch(NavigationActions.back());
return true;
};
_getUserData = async () => {
const { dispatch } = this.props;
let realmData;