Created
October 27, 2017 19:08
-
-
Save godie007/bd5578cc678a0f4f6c0a550d97f7006d to your computer and use it in GitHub Desktop.
Back hardware react native
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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