React-native-router-flux: question about back button in example app

Created on 6 Nov 2018  ·  3Comments  ·  Source: aksonov/react-native-router-flux

Hi there,

I just installed your demo app on Android and it seems it uses
"react-native-router-flux": "^4.0.4",
and when I stay on first screen and hit back button then nothing happens (I am not able to quit the app). is it exactly how it suppose to work?

bug help wanted

Most helpful comment

if anyone else has the same problem i have a temporary workaround for this problem. Add the following code to the class where you declare your router. That way you can have a way to exit app by using back button in Android

import {BackHandler} from 'react-native'
  componentDidMount(){
  BackHandler.addEventListener('hardwareBackPress', function() {
  if (Actions.currentScene == 'your home screen name')
    BackHandler.exitApp()
});
  }

componentWillUnmount(){
  BackHandler.removeEventListener('hardwareBackPress', function() {
    if (Actions.currentScene == 'your home screen name')
      BackHandler.exitApp()
  })
}

and remember to change 'your home screen name' to the home screen key of your app.

All 3 comments

It is not good and should be fixed for sure. Unfortunately I don’t have enough time to work on it, PR is welcome!

6 нояб. 2018 г., в 10:15, Roman notifications@github.com написал(а):

Hi there,

I just installed your demo app https://github.com/aksonov/react-native-router-flux/tree/master/examples/react-native and it seems it uses
"react-native-router-flux": "^4.0.4",
and when I stay on first screen and hit back button then nothing happens (I am not able to quit the app). is it exactly how it suppose to work?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub https://github.com/aksonov/react-native-router-flux/issues/3347, or mute the thread https://github.com/notifications/unsubscribe-auth/ABQpcSuXCEEwRooX8wK4r1CWDX_GWjy4ks5usdHZgaJpZM4YRAMi.

Duplicate of #3337

if anyone else has the same problem i have a temporary workaround for this problem. Add the following code to the class where you declare your router. That way you can have a way to exit app by using back button in Android

import {BackHandler} from 'react-native'
  componentDidMount(){
  BackHandler.addEventListener('hardwareBackPress', function() {
  if (Actions.currentScene == 'your home screen name')
    BackHandler.exitApp()
});
  }

componentWillUnmount(){
  BackHandler.removeEventListener('hardwareBackPress', function() {
    if (Actions.currentScene == 'your home screen name')
      BackHandler.exitApp()
  })
}

and remember to change 'your home screen name' to the home screen key of your app.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VictorK1902 picture VictorK1902  ·  3Comments

maphongba008 picture maphongba008  ·  3Comments

basdvries picture basdvries  ·  3Comments

moaxaca picture moaxaca  ·  3Comments

llgoer picture llgoer  ·  3Comments