question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Leaving a stack and going back to a tab doesn't work - NativeStack

See original GitHub issue

Description

I’m trying to get out of a stack and go to a tab, but it has an unexpected behavior

https://user-images.githubusercontent.com/68711690/134956791-d38e60ee-d7e1-4303-95ad-e5c2058af74f.mp4

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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Ralisson-Mattiascommented, Sep 28, 2021

ok I will create

0reactions
WoLewickicommented, Sep 28, 2021

If you cannot reproduce it in snack, please make a simple repository with the minimal needed code in App.js and 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 provide detachInactiveScreens: false in normal stack?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found