kanzitelli / rnn-starter

🤹 React Native Starter - Powered by cli-rn, React Native Navigation, Expo Modules, RNN Screens, RN UI lib, MMKV, Mobx, Reanimated 2, Dark Mode, Splash Screen, Localization, Notifications, Permissions, and much more.
https://starters.dev
MIT License
551 stars 72 forks source link

Harware back button on android closes the app on the last tab. #104

Closed Yasir5247 closed 2 years ago

Yasir5247 commented 2 years ago

image i had three tabs in my app.

Tab1 -> Tab2 -> Tab3

on Tab3 if i press hardware button on android it directly closes the app like this

close <- Tab3(press)

here is how i feel it should be when the user press hardware back button on Tab3

close <-Tab1 <- Tab2 <- Tab3(press)

possible solutions according to i know:

On Tab3 if the user press the hardware back button. switch to Tab2 programatically and on Tab2 switch to Tab1 ...close. Is there any automatic way to achieve this through some configuration that i' don't know of. :)

kanzitelli commented 2 years ago

This issue is not related to the starter. It's behaviour of RNN how it is. The only solution that comes to my mind is to subscribe to tab presses, save the history and on hardware back button press navigate back according to the stack. This kind of behaviour is automatically achieved in react-navigation as it uses different approach.