Current Behavior
My react-native application consists of a BottomTabNavigator that contains several StackNavigators. A simplified example of my structure looks like this
userLoggedIn or signinSkiped ? (
BottomTab
- Tab 1
Stack
Screen 1
Screen 2
- Tab 2
Stack
Screen 1
Screen 2
) : ( Stack
SigninScreen
RegisterScreen
)
**My problem is: **
- I log in into my application
- I am on Screen 1 of the Tab 1.
- From the Screen 1 of the Tab 1 i navigate to Screen 2 of the Tab 1 on the press button.
- From the Screen 2 of the Tab 1 i navigate to Screen 2 of the Tab 2 on the press button.
- I log out from my application
- I am on SigninScreen
- I click on the button "signinSkip" on the SigninScreen (signinSkiped = true)
- I am on the Screen 1 of the Tab 1
- I click on Tab 2
- Screen 2 of the Tab 2 is displayed
**Expected behavior: **
When I click on Tab 2 as described in the step 9 above, Screen 1 of the Tab 2 should be displayed and not the Screen 2.
It works as expected, if I do following steps:
- I sign in into my application
- I am on the Screen 1 of the Tab 1
- I click on Tab 2 and I'm on the Screen 1 of the Tab 2
- From the Screen 1 of the Tab 2 i navigate to Screen 2 of the Tab 2 on the press button.
- I log out from my application
- I am on SigninScreen
- I click on the button "signinSkip" on the SigninScreen (signinSkiped = true)
- I am on the Screen 1 of the Tab 1
- I click on Tab 2
- Screen 1 of the Tab 2 is displayed
I assume, it has to do with refreshing of stack after logging out, but I'm not sure. i would really appreciate your help
I tried following:
Navigate from Screen 2 to Screen 1 of the Tab 2 if the user loggs out (within the onAuthStateChanged listener). I get the expected result, but it leads to the error: Can't perform a React state update on an unmounted component