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 not working in initial Scene #2413

Closed
aston-xie opened this issue Sep 21, 2017 · 11 comments
Closed

BackHandler not working in initial Scene #2413

aston-xie opened this issue Sep 21, 2017 · 11 comments
Labels

Comments

@aston-xie
Copy link

Version

Tell us which versions you are using:

  • react-native-router-flux v4.0.0-beta.21 (v3 is not supported)
  • react-native v0.48.3

Expected behaviour

exit app

Actual behaviour

not working

Steps to reproduce

For non-obvious bugs, please fork this component, modify Example project to reproduce your issue and include link here.

  1. BackHandler.addEventListener('hardwareBackPress', this.onBackAndroid);
  2. BackHandler not working in initial Scene
  3. working in other Scene
@RobTS
Copy link

RobTS commented Oct 9, 2017

Same for me...

@mikesol
Copy link

mikesol commented Oct 11, 2017

Same here...

@jash90
Copy link

jash90 commented Oct 17, 2017

<Router
                backAndroidHandler={() => {
                if (Actions.currentScene == "name your Scene") {
                    if (backLoginScene == false) {
                        ToastAndroid.show("Click back again to exit.", ToastAndroid.SHORT);
                        backLoginScene = !backLoginScene;
                        return true;
                    } else {
                        backLoginScene = false;
                        BackHandler.exitApp();
                    }
                    return false;
                }}}>

@jash90
Copy link

jash90 commented Oct 17, 2017

You must add backAndroidHandler in Router

@Maxitk
Copy link

Maxitk commented Nov 10, 2017

my version is 4.0.0-beta.23
i have add Router,but it doesn't run backAndroidHandler when i press back

@aksonov
Copy link
Owner

aksonov commented Nov 10, 2017

@Maxitk Please check latest master now.

@Maxitk
Copy link

Maxitk commented Nov 12, 2017

@aksonov ok,i will try it tomorrow,thanks...

@Maxitk
Copy link

Maxitk commented Nov 13, 2017

@aksonov i have tried it a moment ago,but the same as before
I have deleted other 'backHandler' in my code and I try to do two things :
1、I add <Router backAndroidHandler...
2、I add backHandler.addEventListener in initial page
both of them didn't work

@kaixinfu
Copy link

please try it.<Router backAndroidHandler={() => {}}>

@vikrantnegi
Copy link

I'm having the same problem.
Here is the StackOverflow question.
https://stackoverflow.com/questions/47898965/exist-app-when-clicked-back-on-home-screen

@aksonov
Copy link
Owner

aksonov commented Jan 5, 2018

Latest Example works fine with hardware back button

@aksonov aksonov closed this as completed Jan 5, 2018
mvanroon pushed a commit to mvanroon/react-native-router-flux that referenced this issue Feb 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants