react-navigation / react-navigation/react-navigation

problem quitting the app when on the wrong screen

Open
#8,922 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug package:bottom-tabs
Dominant language
TypeScript
Stars
24.5k
Forks
5.1k
Avg merge
1d 5h
Merged PRs (30d)
18

Description

Current Behavior

  • The first screen that opens is the home screen, I go to the settings screen through the tabbar and come back to the home screen through the tabbar. Then, while on the home screen, I press the android back button and go to the settings screen. When I press the android back button again, the application quits

rn

Expected Behavior

  • I am waiting for the application to exit when I press the android back button while on the home screen.

Code Sample

const HomeStack = createStackNavigator();

function HomeStackScreen() {
    return (
        <HomeStack.Navigator>
            <HomeStack.Screen name="Home" component={Home} />
            <HomeStack.Screen name="Detail" component={Detail} />
        </HomeStack.Navigator>
    );
}

const SettingsStack = createStackNavigator();

function SettingsStackScreen() {
    return (
        <SettingsStack.Navigator>
            <SettingsStack.Screen name="Settings" component={Settings} />
            <SettingsStack.Screen name="Profile" component={Profile} />
        </SettingsStack.Navigator>
    );
}

const Tab = createBottomTabNavigator();

function MainTabs() {
    return (
        <Tab.Navigator>
            <Tab.Screen name="Home" component={HomeStackScreen} />
            <Tab.Screen name="Settings" component={SettingsStackScreen} />
        </Tab.Navigator>
    )
}

const RootStack = createStackNavigator();

return (
    <NavigationContainer>
        <RootStack.Navigator>
            <RootStack.Screen name="Main" component={MainTabs} />
        </RootStack.Navigator>
    </NavigationContainer>
);

Your Environment

software version
iOS or Android Android
@react-navigation/native ^5.7.4
@react-navigation/stack ^5.9.1
@react-navigation/bottom-tabs ^5.9.0
react-native-gesture-handler ^1.8.0
react-native-safe-area-context ^3.1.8
react-native-screens ^2.11.0
react-native 0.63.2
expo
node v12.18.3
npm or yarn npm

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Android back-button sequence described with the HomeStack, SettingsStack, MainTabs, and RootStack navigation structure. Trace how tab changes affect the navigation state, then verify that pressing back from the settings screen after returning to home exits as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.