Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. Use Case :
  2.  
  3. import { BackHandler } from 'react-native'
  4.  
  5. componentDidMount() {
  6. BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
  7. }
  8.  
  9. componentWillUnmount() {
  10. BackHandler.removeEventListener('hardwareBackPress', this.handleBackPress);
  11. }
  12.  
  13. handleBackPress = () => {
  14. this.goBack(); // works best when the goBack is async
  15. return true;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement