Leaving a stack and going back to a tab doesn't work - NativeStack
See original GitHub issueDescription
I’m trying to get out of a stack and go to a tab, but it has an unexpected behavior
Application crashes
Expected behavior
The application returns to the start screen normally
Actual behavior
Application does not go back to start screen and there is a jump on start screen
Snack or minimal code example
Router index code example
export function Routes() {
return (
<NavigationContainer>
<Stack />
</NavigationContainer>
)
}
BottomTab code example
export function Bottom() {
return (
<Navigator
screenOptions={{
headerShown: false,
tabBarShowLabel: false,
tabBarInactiveTintColor: colors.gray_1,
tabBarActiveTintColor: colors.blue_1,
tabBarStyle: {
elevation: 0,
borderTopWidth: 0,
height: 80
},
}}
>
<Screen
name="Home"
component={Home}
options={{
tabBarIcon: ({ color, focused, size }) => (
<View style={[styles.container, { backgroundColor: focused ? "rgba(7,85,219,.1)" : "#fff" }]}>
<MCI
name={focused ? "home-variant" : "home-variant-outline"}
size={size}
color={color}
/>
</View>
)
}}
/>
</Navigator>
)
}
NativeStack code example
import { createNativeStackNavigator } from "@react-navigation/native-stack"
export function Stack() {
return (
<Navigator
screenOptions={{
headerShown: false,
}}
>
<Screen
name="Bottom"
component={Bottom}
/>
<Screen
name="Notification"
component={Notification}
/>
</Navigator>
)
}
Code example of the button back
import { useNavigation } from "@react-navigation/core"
export function Header() {
const navigation = useNavigation()
return (
<View>
<ButtonBack onPress={() => navigation.navigate("Bottom")} />
</View>
)
}
Package versions
@react-navigation/native-stack: 6.1.0
- React: 17.0.2
- React Native: 0.65.1
- React Native Screens: 3.7.2
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Navigating to Nested Stack Navigator Doesn't Show Go Back ...
Current Behavior I have a Bottom Tab Navigator that controls the main bottom navigation. Each "tab" is a stack navigation component.
Read more >How to reach to the top of the stack when pressing tab in react ...
If you don't want that feature, you can add 'Tab' into 'Stack'. ... so that you are in the first screen when you...
Read more >Combining Stack, Tab & Drawer Navigations in React Native ...
In drawer navigation, when I go forth and back in my screens, the screen freezes. In the beginning, I search all of my...
Read more >Native Stack Navigator | React Navigation
Native Stack Navigator provides a way for your app to transition between screens where each new screen is placed on top of a...
Read more >Combining Stack Navigation with Tab Navigation in React ...
So, we create stack navigator in each page of the tabs, so that you can go to the details screen through the help...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

ok I will create
If you cannot reproduce it in snack, please make a simple repository with the minimal needed code in
App.jsand we will copy it to our project and test it there. Unfortunately I cannot tell much from just logs. Also, does it happen in normal stack? And if so, does it happen if you providedetachInactiveScreens: falsein normal stack?