0

I have a DrawerNavigator as the basic block of my app. The reason is that it should be accessible from all screens. As such, it's also the target for all deep links and will only display some of the items in the actual drawer.

The main page consists of a bottom navigator of stacks, and more entries are also stacks themselves.

The problem is that navigating in the drawer doesn't show any back button as navigating in the stacks would. And it would be nice to have these, just like the back gesture on Android works.

Is this something that exists and if yes, how should it be tackled?

Matthieu Brucher
  • 21,634
  • 7
  • 38
  • 62

1 Answers1

1

You'll need your own header component in each screen which has a back button. You can use a custom one or one from a component library such as react native paper.

function Home({ navigation }) {
  return (
    <React.Fragment>
      <MyCustomHeader title="Home" onBackPress={navigation.goBack} />
      {{
        /* screen content */
      }}
    </React.Fragment>
  );
}

Make sure you pass backBehavior: 'history' to createDrawerNavigator.

satya164
  • 9,464
  • 2
  • 31
  • 42