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

Android hardware back button does not run onBack function #2359

Closed
ynsgnr opened this issue Sep 9, 2017 · 3 comments
Closed

Android hardware back button does not run onBack function #2359

ynsgnr opened this issue Sep 9, 2017 · 3 comments

Comments

@ynsgnr
Copy link

ynsgnr commented Sep 9, 2017

Version

Tell us which versions you are using:

  • react-native-router-flux v4.beta21 (v3 is not supported)
  • react-native v0.48

When Android hardware back button pressed onBack function is not called. I dont know if its intentinal or not and can be solved by adding an event on BackHandler and returning true in function but i think that this should be mentioned in docs.

Thank you for your efforts, if you want i can add this into docs

@aksonov
Copy link
Owner

aksonov commented Sep 10, 2017

You are right, BackHandler should be used, feel free to submit PR for docs.

@aksonov aksonov closed this as completed Sep 10, 2017
@CodeRabbitYu
Copy link

What is your solution? Can I provide the code?

@ynsgnr
Copy link
Author

ynsgnr commented Sep 13, 2017

`componentDidMount(){
BackHandler.addEventListener('hardwareBackPress', this.handleAndroidBack)
}

componentWillUnmount(){
BackHandler.removeEventListener('hardwareBackPress', this.handleAndroidBack)
}

handleAndroidBack = () =>{
//Add desired function here (onBack in this case)
Actions.pop();
return true
}`

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

3 participants