← Back to Chapters

React Native Navigation Overview

? React Native Navigation Overview

? Quick Overview

React Native navigation allows users to move between different screens in a mobile application. It manages screen transitions, headers, history stacks, and user flow across the app.

? Key Concepts

  • Navigation Container
  • Stack Navigation
  • Tab Navigation
  • Drawer Navigation
  • Screen Components

? Syntax / Theory

React Native navigation is commonly implemented using the @react-navigation library. It wraps the app inside a navigation container and defines navigators to control screen flow.

? View Code Example
// Import navigation container from react-navigation
import { NavigationContainer } from '@react-navigation/native';

export default function App() {
return (
<NavigationContainer>
</NavigationContainer>
);
}

? Code Example(s)

? View Code Example
// Basic stack navigation setup
import { createNativeStackNavigator } from '@react-navigation/native-stack';

const Stack = createNativeStackNavigator();

function AppNavigator() {
return (
<Stack.Navigator>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Profile" component={ProfileScreen} />
</Stack.Navigator>
);
}

? Live Output / Explanation

What Happens?

The app starts on the Home screen. When navigation actions are triggered, the stack pushes or pops screens while maintaining navigation history.

? Interactive Example / Visual Flow

Use the simulated phone below to understand how Stack Navigation works. Notice how screens stack on top of each other.

9:41 ?

? Home Screen

This is the bottom of the stack.

? Profile Screen

You pushed a new screen.

⚙️ Settings

Top of the stack.

Press back to pop.

Current Stack: [ Home ]

? Use Cases

  • Multi-screen mobile applications
  • User authentication flows
  • Tabbed dashboards
  • Side-menu based apps

? Tips & Best Practices

  • Wrap only one NavigationContainer in the app
  • Keep screen components small and focused
  • Use stack navigation for linear flows

? Try It Yourself

  1. Create two screens: Home and About
  2. Add a stack navigator
  3. Navigate using a button press