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.

[Android] Pushing to a new independent stack on android shows the back button

See original GitHub issue

Pushing to the following independent navigation container, I’d expect the back button to be hidden as it’s at the start of the stack. I can work around it at the moment by forcing headerHideBackButton, however this is a bit of a hack.

        <NavigationContainer independent>
            <Navigator screenOptions={defaultNavigationOptions} initialRouteName={RouteUrls.home}>
                <Stack.Screen
                  name={RouteUrls.home}
                  options={{...routes[RouteUrls.home].options, headerHideBackButton: true}}
                  component={routes[RouteUrls.home].component}
        />
                <Stack.Screen
                  name={RouteUrls.generic}
                  options={routes[RouteUrls.generic].options}
                  component={routes[RouteUrls.generic].component}
        />
                <Stack.Screen
                  name={RouteUrls.stack}
                  options={routes[RouteUrls.stack].options}
                  component={routes[RouteUrls.stack].component}
        />
            </Navigator>
        </NavigationContainer>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
kyle-ssgcommented, Aug 6, 2020

Thanks for looking at this, by the way I have to say so far this is an outstanding package! Glad so far to be transitioning away from react-native-navigation to this.

1reaction
WoLewickicommented, Aug 6, 2020

In https://github.com/software-mansion/react-native-screens/blob/master/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.java#L189 you can change that if to return ((ScreenStack) container).getRootScreen() != getScreen(); and comment the code below it. I will look at why it is implemented like that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tasks and the back stack | Android Developers
When the current activity starts another, the new activity is pushed on the top of the stack and takes focus. The previous activity...
Read more >
how to go back to previous fragment on pressing manually ...
You can call the popFragments() whenever you click the back button in a fragment and call pushFragments() whenever you navigate from one Fragment...
Read more >
Multiple back stacks. A deep dive | by Ian Lake - Medium
If a 'back stack' is a set of screens that you can navigate back through via the system back button, 'multiple back stacks'...
Read more >
Handling Back Button in Android without implementing ...
I have used a boolean flag to get to know that if back button is kept pressed from last screen, it won't exit...
Read more >
How to Implement Press Back Again to Exit in Android?
In the above code, when the user presses the 'BACK' button once, they are greeted with a toast asking them to press it...
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