Navigation Lifecycle

React Native 6 min min read Updated: Jul 26, 2026 Intermediate
Navigation Lifecycle
Intermediate Topic 8 of 15

Navigation Lifecycle

Unlike a typical component lifecycle, screens managed by React Navigation remain mounted even when not visible, requiring special lifecycle events to detect when a screen becomes focused or unfocused.

Why Screens Stay Mounted

In a stack navigator, previous screens remain in memory so that navigating back is instant, without needing to reload the entire screen from scratch.

Using the useFocusEffect Hook

The useFocusEffect hook runs its callback every time the screen comes into focus, and its cleanup function when the screen loses focus.

javascript import { useFocusEffect } from '@react-navigation/native'; import { useCallback } from 'react'; function ProfileScreen() { useFocusEffect( useCallback(() => { console.log('Screen focused'); return () => console.log('Screen unfocused'); }, []) ); return Profile; }

Using the useIsFocused Hook

The useIsFocused hook returns a boolean value indicating whether the current screen is focused, useful for conditionally pausing or resuming logic like video playback.

javascript import { useIsFocused } from '@react-navigation/native'; const isFocused = useIsFocused();

Listening to Navigation Events

You can also directly listen to "focus" and "blur" events using the navigation object, offering an alternative to hooks for class components or specific edge cases.

javascript useEffect(() => { const unsubscribe = navigation.addListener('focus', () => { console.log('Screen focused via listener'); }); return unsubscribe; }, [navigation]);

Common Use Cases

  • Refreshing data every time a screen becomes visible
  • Pausing video or audio playback when navigating away
  • Resetting form state when returning to a screen

Conclusion

Understanding navigation lifecycle events like useFocusEffect and useIsFocused is essential for building React Native apps that behave correctly as users move between screens without unmounting and remounting components unnecessarily.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators