Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BackHandler.addEventListener('hardwareBackPress', this._clickBack); #18

Open
GuoJiKaiHehe opened this issue Apr 15, 2020 · 1 comment
Open

Comments

@GuoJiKaiHehe
Copy link

GuoJiKaiHehe commented Apr 15, 2020

监听安卓返回键,不生效
BackHandler.addEventListener('hardwareBackPress', this._clickBack);

@JairFsl
Copy link

JairFsl commented Nov 14, 2023

You can try this:

.
.
.

import { useBackHandler } from '@react-native-community/hooks'

.
.
.

useBackHandler(() => {
    //your function
    Alert.alert('Teste')
    
    // Return True will remove BackPress Event, if you set False it will allow it to run your function but will have the BackPress Event anyway.
    return true
  })

@1NxT
@Kiluameta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants