You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before continuing, first install and configure [`@react-navigation/drawer`](https://github.com/react-navigation/react-navigation/tree/main/packages/drawer) and its dependencies following the [installation instructions](drawer-navigator.md#installation).
13
19
14
20
## Minimal example of drawer-based navigation
@@ -111,11 +117,6 @@ export default function App() {
When we define our button this way, the `this` variable in `options` is _not_ the `HomeScreen` instance, so you can't call `setState` or any instance methods on it. This is pretty important because it's extremely common to want the buttons in your header to interact with the screen that the header belongs to. So, we will look how to do this next.
When we define our button this way, the `this` variable in `options` is _not_ the `HomeScreen` instance, so you can't call `setState` or any instance methods on it. This is pretty important because it's common to want the buttons in your header to interact with the screen that the header belongs to. So, we will look how to do this next.
112
111
113
112
:::tip
@@ -173,11 +172,6 @@ export default function App() {
Copy file name to clipboardExpand all lines: versioned_docs/version-7.x/headers.md
+2-1
Original file line number
Diff line number
Diff line change
@@ -98,10 +98,11 @@ export default function App() {
98
98
}
99
99
```
100
100
101
-

102
101
</TabItem>
103
102
</Tabs>
104
103
104
+

105
+
105
106
## Using params in the title
106
107
107
108
In order to use params in the title, we need to make `options` for the screen a function that returns a configuration object. If we make `options` a function then React Navigation will call it with an object containing `{ navigation, route }` - in this case, all we care about is `route`, which is the same object that is passed to your screen props as `route` prop. You may recall that we can get the params through `route.params`, and so we do this below to extract a param and use it as a title.
Here, we are creating 2 groups of screens using the `RootStack.Group` component. The first group is for our regular screens, and the second group is for our modal screens. For the modal group, we have specified `presentation: 'modal'` in `screenOptions`. This will apply this option to all the screens inside the group. This option will change the animation for the screens to animate from bottom-to-top rather than right to left. The `presentation` option for stack navigator can be either `card` (default) or `modal`. The `modal` behavior slides the screen in from the bottom and allows the user to swipe down from the top to dismiss it on iOS.
But there is one problem. When we call `navigation.openDrawer()` in our `HomeScreen`, it always opens the left drawer since it's the immediate parent of the screen.
> On Android, React Navigation hooks in to the hardware back button and fires the `goBack()`function for you when the user presses it, so it behaves as the user would expect.
258
251
// codeblock-focus-start
259
252
functionDetailsScreen() {
260
253
constnavigation=useNavigation();
@@ -289,6 +282,12 @@ export default function App() {
On Android, React Navigation hooks in to the hardware back button and fires the `goBack()` function for you when the user presses it, so it behaves as the user would expect.
This is similar to how you would customize a stack navigator — there are some properties that are set when you initialize the tab navigator and others that can be customized per-screen in `options`.
0 commit comments