I am handling the Android back button in React-Native using BackHandler in home page its working fine, when i navigate to home page from login page. But when i go to page 2 from home page and came back to home page by clicking the device back button, now when i click device back button in home page its taking me to login page, this should not happen. Navigation used in home page is a drawer navigation. I am removing the backpress event handler when i am navigating to page2, because it is disabling the back button in page 2 also.
Asked
Active
Viewed 735 times
1
-
You should have two stacks, one for login, the other for you app, and reset the stack to the app stack upon login. That way you don't have to worry about swiping back either, and you can program your back button to actually work, and not disable functionality. – AnonymousSB Nov 20 '18 at 09:49
-
can u provide a sample example for above – Sreedhar L Nov 26 '18 at 11:22
-
[Here's a stripped down version of what I use](https://gist.github.com/AnonymousSB/0257ccce4709d895811a2a9eed73ae18). I'm using `redux` and `redux-saga`. This particular snippet is from an app using `react-navigation ^1.0.0-beta.15` – AnonymousSB Nov 26 '18 at 11:44
-
how to load images from a resources folders like drawable/mipmap in react native app – Sreedhar L Nov 29 '18 at 06:59
-
You really should post that as a separate question. To the best of my knowledge you don't. Even if you could, that would be a very bad programming practice. Theoretically you could create a [Native Module](https://facebook.github.io/react-native/docs/native-modules-ios) to do this, or maybe someone has already made one. – AnonymousSB Nov 29 '18 at 07:13
1 Answers
2
You just have to implement the Backhandler in your home page, and don't perform any action on it.
BackHandler.addEventListener('hardwareBackPress', () => {
return false
});
Just return false. So It won't navigation to Login screen again.

Nirmalsinh Rathod
- 5,079
- 4
- 26
- 56
-
how to load images from a resources folders like drawable/mipmap in react native app – Sreedhar L Nov 29 '18 at 06:58
-
You need to give path of your image. You need to add image on one of your folder, not in particular iOS and Android folder. – Nirmalsinh Rathod Nov 29 '18 at 07:00