What is React Navigation?
Why Interviewers Ask This
This is a classic screening question for React Native roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.
Answer
React Navigation is the most popular navigation library for React Native, providing a complete navigation solution. React Native has no built-in navigation (unlike web browsers). Installation: npm install @react-navigation/native @react-navigation/stack @react-navigation/bottom-tabs react-native-screens react-native-safe-area-context. Setup: wrap app in NavigationContainer: import { NavigationContainer } from "@react-navigation/native"; export default function App() { return ( <NavigationContainer> <RootNavigator /> </NavigationContainer> ); }. Stack Navigator: push/pop screens (back gesture, back button): import { createNativeStackNavigator } from "@react-navigation/native-stack"; const Stack = createNativeStackNavigator(); function RootNavigator() { return ( <Stack.Navigator initialRouteName="Home"> <Stack.Screen name="Home" component={HomeScreen} /> <Stack.Screen name="Detail" component={DetailScreen} /> </Stack.Navigator> ); } // Navigating: navigation.navigate("Detail", { id: 123 }) navigation.goBack(). Bottom Tab Navigator: tab bar at bottom: const Tab = createBottomTabNavigator(); <Tab.Navigator> <Tab.Screen name="Home" component={HomeScreen} /> <Tab.Screen name="Profile" component={ProfileScreen} /> </Tab.Navigator>. Accessing navigation: via props (navigation, route) or hooks: const navigation = useNavigation(); const route = useRoute();. Expo Router: file-based routing (like Next.js) — modern alternative for Expo projects.
Pro Tip
Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex React Native answers easy to follow.
Previous
What is the difference between FlatList and ScrollView?
Next
What is the difference between TouchableOpacity, TouchableHighlight, and Pressable?