Skip to content

Instantly share code, notes, and snippets.

@godie007
Created October 27, 2017 19:08
Show Gist options
  • Select an option

  • Save godie007/bd5578cc678a0f4f6c0a550d97f7006d to your computer and use it in GitHub Desktop.

Select an option

Save godie007/bd5578cc678a0f4f6c0a550d97f7006d to your computer and use it in GitHub Desktop.
Back hardware react native
import { BackHandler } from 'react-native';
componentWillMount() {
BackHandler.addEventListener('hardwareBackPress', this.onBackPress.bind(this));
}
onBackPress(){
if(this.props.isAuthenticated){
const { state, dispatch } = this.props.navigation;
dispatch({
type: 'Reset',
index: 0,
actions: [
{
type: 'Navigate',
routeName: 'list',
},
],
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment