Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Use Case :
- import { BackHandler } from 'react-native'
- componentDidMount() {
- BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
- }
- componentWillUnmount() {
- BackHandler.removeEventListener('hardwareBackPress', this.handleBackPress);
- }
- handleBackPress = () => {
- this.goBack(); // works best when the goBack is async
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement