Skip to content

Commit 1346c11

Browse files
committed
Add info about navigation prop to drawer content and tab bar
1 parent 4fdd357 commit 1346c11

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

versioned_docs/version-5.x/bottom-tab-navigator.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,22 @@ function MyTabBar({ state, descriptors, navigation }) {
145145

146146
This example will render a basic tab bar with labels.
147147

148+
Note that you **cannot** use the `useNavigation` hook inside the `tabBar` since `useNavigation` is only available inside screens. You get a `navigation` prop for your `tabBar` which you can use instead:
149+
150+
```js
151+
function MyTabBar({ navigation }) {
152+
return (
153+
<Button
154+
title="Go somewhere"
155+
onPress={() => {
156+
// Navigate using the `navigation` prop that you received
157+
navigation.navigate('SomeScreen');
158+
}}
159+
/>
160+
);
161+
}
162+
```
163+
148164
#### `tabBarOptions`
149165

150166
An object containing the props for the default tab bar component. If you're using a custom tab bar, these will be passed as props to the tab bar and you can handle them.

versioned_docs/version-5.x/drawer-navigator.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,22 @@ function CustomDrawerContent({ progress, ...rest }) {
265265
}
266266
```
267267

268+
Note that you **cannot** use the `useNavigation` hook inside the `drawerContent` since `useNavigation` is only available inside screens. You get a `navigation` prop for your `drawerContent` which you can use instead:
269+
270+
```js
271+
function CustomDrawerContent({ navigation }) {
272+
return (
273+
<Button
274+
title="Go somewhere"
275+
onPress={() => {
276+
// Navigate using the `navigation` prop that you received
277+
navigation.navigate('SomeScreen');
278+
}}
279+
/>
280+
);
281+
}
282+
```
283+
268284
To use the custom component, we need to pass it in the `drawerContent` prop:
269285

270286
```js

versioned_docs/version-5.x/material-top-tab-navigator.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,22 @@ function MyTabBar({ state, descriptors, navigation, position }) {
255255

256256
This example will render a basic tab bar with labels.
257257

258+
Note that you **cannot** use the `useNavigation` hook inside the `tabBar` since `useNavigation` is only available inside screens. You get a `navigation` prop for your `tabBar` which you can use instead:
259+
260+
```js
261+
function MyTabBar({ navigation }) {
262+
return (
263+
<Button
264+
title="Go somewhere"
265+
onPress={() => {
266+
// Navigate using the `navigation` prop that you received
267+
navigation.navigate('SomeScreen');
268+
}}
269+
/>
270+
);
271+
}
272+
```
273+
258274
#### `tabBarOptions`
259275

260276
An object containing the props for the tab bar component. It can contain the following properties:

0 commit comments

Comments
 (0)