Skip to content

Commit 764039f

Browse files
committed
docs: Updated lifecycle videos in Fundamentals
1 parent 251d152 commit 764039f

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed
Binary file not shown.
Binary file not shown.

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function App() {
5151
```
5252

5353
<video playsInline autoPlay muted loop>
54-
<source src="/assets/navigators/lifecycle.mp4" />
54+
<source src="/assets/7.x/fundamentals/navigationLifecycle.mp4" />
5555
</video>
5656

5757
We start on the `HomeScreen` and navigate to `DetailsScreen`. Then we use the tab bar to switch to the `SettingsScreen` and navigate to `ProfileScreen`. After this sequence of operations is done, all 4 of the screens are mounted! If you use the tab bar to switch back to the `HomeStack`, you'll notice you'll be presented with the `DetailsScreen` - the navigation state of the `HomeStack` has been preserved!
@@ -96,10 +96,12 @@ function Profile() {
9696
useFocusEffect(
9797
React.useCallback(() => {
9898
// Do something when the screen is focused
99-
99+
Alert.alert("ProfileScreen focus effect");
100+
100101
return () => {
101102
// Do something when the screen is unfocused
102103
// Useful for cleanup functions
104+
Alert.alert("ProfileScreen focus effect cleanup");
103105
};
104106
}, [])
105107
);
@@ -109,7 +111,7 @@ function Profile() {
109111
```
110112

111113
<video playsInline autoPlay muted loop>
112-
<source src="/assets/navigators/lifecycle-focus.mp4" />
114+
<source src="/assets/7.x/fundamentals/lifecycleEvents.mp4" />
113115
</video>
114116

115117
If you want to render different things based on if the screen is focused or not, you can use the [`useIsFocused`](use-is-focused.md) hook which returns a boolean indicating whether the screen is focused.

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ export default function App() {
277277
</Tabs>
278278

279279
<video playsInline autoPlay muted loop>
280-
<source src="/assets/navigators/lifecycle.mp4" />
280+
<source src="/assets/7.x/fundamentals/navigationLifecycle.mp4" />
281281
</video>
282282

283283
We start on the `HomeScreen` and navigate to `DetailsScreen`. Then we use the tab bar to switch to the `SettingsScreen` and navigate to `ProfileScreen`. After this sequence of operations is done, all 4 of the screens are mounted! If you use the tab bar to switch back to the `HomeStack`, you'll notice you'll be presented with the `DetailsScreen` - the navigation state of the `HomeStack` has been preserved!
@@ -295,7 +295,7 @@ Example:
295295

296296
```js name="Focus and blur" snack
297297
import * as React from 'react';
298-
import { Text, View } from 'react-native';
298+
import { Text, View, Alert } from 'react-native';
299299
import {
300300
createStaticNavigation,
301301
useNavigation,
@@ -310,7 +310,7 @@ function ProfileScreen() {
310310
React.useEffect(() => {
311311
// highlight-start
312312
const unsubscribe = navigation.addListener('focus', () => {
313-
console.log('ProfileScreen focused');
313+
Alert.alert('ProfileScreen focused');
314314
});
315315
// highlight-end
316316

@@ -320,7 +320,7 @@ function ProfileScreen() {
320320
React.useEffect(() => {
321321
// highlight-start
322322
const unsubscribe = navigation.addListener('blur', () => {
323-
console.log('ProfileScreen blurred');
323+
Alert.alert('ProfileScreen blurred');
324324
});
325325
// highlight-end
326326

@@ -383,7 +383,7 @@ export default function App() {
383383

384384
```js name="Focus and blur" snack
385385
import * as React from 'react';
386-
import { Text, View } from 'react-native';
386+
import { Text, View, Alert } from 'react-native';
387387
import { NavigationContainer, useNavigation } from '@react-navigation/native';
388388
import { createNativeStackNavigator } from '@react-navigation/native-stack';
389389
import { Button } from '@react-navigation/elements';
@@ -395,7 +395,7 @@ function ProfileScreen() {
395395
React.useEffect(() => {
396396
// highlight-start
397397
const unsubscribe = navigation.addListener('focus', () => {
398-
console.log('ProfileScreen focused');
398+
Alert.alert('ProfileScreen focused');
399399
});
400400
// highlight-end
401401

@@ -405,7 +405,7 @@ function ProfileScreen() {
405405
React.useEffect(() => {
406406
// highlight-start
407407
const unsubscribe = navigation.addListener('blur', () => {
408-
console.log('ProfileScreen blurred');
408+
Alert.alert('ProfileScreen blurred');
409409
});
410410
// highlight-end
411411

@@ -425,15 +425,15 @@ function HomeScreen() {
425425

426426
React.useEffect(() => {
427427
const unsubscribe = navigation.addListener('focus', () => {
428-
console.log('HomeScreen focused');
428+
Alert.alert('HomeScreen focused');
429429
});
430430

431431
return unsubscribe;
432432
}, [navigation]);
433433

434434
React.useEffect(() => {
435435
const unsubscribe = navigation.addListener('blur', () => {
436-
console.log('HomeScreen blurred');
436+
Alert.alert('HomeScreen blurred');
437437
});
438438

439439
return unsubscribe;
@@ -483,7 +483,7 @@ Example:
483483

484484
```js name="Focus effect" snack
485485
import * as React from 'react';
486-
import { Text, View } from 'react-native';
486+
import { Text, View, Alert } from 'react-native';
487487
import {
488488
createStaticNavigation,
489489
useNavigation,
@@ -498,12 +498,12 @@ function ProfileScreen() {
498498
useFocusEffect(
499499
React.useCallback(() => {
500500
// Do something when the screen is focused
501-
console.log('ProfileScreen focus effect');
501+
Alert.alert('ProfileScreen focus effect');
502502

503503
return () => {
504504
// Do something when the screen is unfocused
505505
// Useful for cleanup functions
506-
console.log('ProfileScreen focus effect cleanup');
506+
Alert.alert('ProfileScreen focus effect cleanup');
507507
};
508508
}, [])
509509
);
@@ -549,7 +549,7 @@ export default function App() {
549549

550550
```js name="Focus effect" snack
551551
import * as React from 'react';
552-
import { Text, View } from 'react-native';
552+
import { Text, View, Alert } from 'react-native';
553553
import { NavigationContainer, useNavigation } from '@react-navigation/native';
554554
import { createNativeStackNavigator } from '@react-navigation/native-stack';
555555
import { Button } from '@react-navigation/elements';
@@ -561,12 +561,12 @@ function ProfileScreen() {
561561
useFocusEffect(
562562
React.useCallback(() => {
563563
// Do something when the screen is focused
564-
console.log('ProfileScreen focus effect');
564+
Alert.alert('ProfileScreen focus effect');
565565

566566
return () => {
567567
// Do something when the screen is unfocused
568568
// Useful for cleanup functions
569-
console.log('ProfileScreen focus effect cleanup');
569+
Alert.alert('ProfileScreen focus effect cleanup');
570570
};
571571
}, [])
572572
);
@@ -617,7 +617,7 @@ export default function App() {
617617
</Tabs>
618618

619619
<video playsInline autoPlay muted loop>
620-
<source src="/assets/navigators/lifecycle-focus.mp4" />
620+
<source src="/assets/7.x/fundamentals/lifecycleEvents.mp4" />
621621
</video>
622622

623623
If you want to render different things based on if the screen is focused or not, you can use the [`useIsFocused`](use-is-focused.md) hook which returns a boolean indicating whether the screen is focused.

0 commit comments

Comments
 (0)