Skip to content

Commit 697af0e

Browse files
committed
Update nesting docs
1 parent e91f647 commit 697af0e

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

versioned_docs/version-7.x/navigation-lifecycle.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
308308
function ProfileScreen() {
309309
const navigation = useNavigation();
310310

311+
// highlight-start
311312
React.useEffect(() => {
312313
const unsubscribe = navigation.addListener('focus', () => {
313314
// Screen was focused
@@ -318,14 +319,17 @@ function ProfileScreen() {
318319

319320
return unsubscribe;
320321
}, [navigation]);
322+
// highlight-end
321323

324+
// highlight-start
322325
React.useEffect(() => {
323326
const unsubscribe = navigation.addListener('blur', () => {
324327
console.log('ProfileScreen blurred');
325328
});
326329

327330
return unsubscribe;
328331
}, [navigation]);
332+
// highlight-end
329333

330334
return (
331335
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
@@ -392,6 +396,7 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
392396
function ProfileScreen() {
393397
const navigation = useNavigation();
394398

399+
395400
React.useEffect(() => {
396401
const unsubscribe = navigation.addListener('focus', () => {
397402
// Screen was focused
@@ -402,14 +407,17 @@ function ProfileScreen() {
402407

403408
return unsubscribe;
404409
}, [navigation]);
410+
// highlight-end
405411

412+
// highlight-start
406413
React.useEffect(() => {
407414
const unsubscribe = navigation.addListener('blur', () => {
408415
console.log('ProfileScreen blurred');
409416
});
410417

411418
return unsubscribe;
412419
}, [navigation]);
420+
// highlight-end
413421

414422
return (
415423
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
@@ -493,8 +501,7 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
493501
import { useFocusEffect } from '@react-navigation/native';
494502

495503
function ProfileScreen() {
496-
const navigation = useNavigation();
497-
504+
// highlight-start
498505
useFocusEffect(
499506
React.useCallback(() => {
500507
// Do something when the screen is focused
@@ -507,6 +514,7 @@ function ProfileScreen() {
507514
};
508515
}, [])
509516
);
517+
// highlight-end
510518

511519
return (
512520
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
@@ -556,8 +564,7 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
556564
import { useFocusEffect } from '@react-navigation/native';
557565

558566
function ProfileScreen() {
559-
const navigation = useNavigation();
560-
567+
// highlight-start
561568
useFocusEffect(
562569
React.useCallback(() => {
563570
// Do something when the screen is focused
@@ -570,6 +577,7 @@ function ProfileScreen() {
570577
};
571578
}, [])
572579
);
580+
// highlight-end
573581

574582
return (
575583
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>

versioned_docs/version-7.x/nesting-navigators.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -798,11 +798,9 @@ navigation.navigate('Root', {
798798

799799
This affects what happens when pressing the back button. When there's an initial screen, the back button will take the user there.
800800

801-
## Nesting multiple navigators
801+
## Avoiding multiple headers when nesting
802802

803-
It's sometimes useful to nest multiple navigators such as stack, drawer or tabs.
804-
805-
When nesting multiple stack, drawer or bottom tab navigator, headers from both child and parent navigators would be shown. However, usually it's more desirable to show the header in the child navigator and hide the header in the screen of the parent navigator.
803+
When nesting multiple stack, drawer or bottom tab navigators, headers from both child and parent navigators would be shown. However, usually it's more desirable to show the header in the child navigator and hide the header in the screen of the parent navigator.
806804

807805
To achieve this, you can hide the header in the screen containing the navigator using the `headerShown: false` option.
808806

0 commit comments

Comments
 (0)