Interview frequency: …
Short answer
Native Stack uses the operating systems' native navigation components (UINavigationController on iOS and FragmentManager on Android) for performance closer to native, while the regular Stack simulates transitions in JavaScript on the JS Thread.
Explanation
@react-navigation/native-stack provides performance closer to native, supports the system's default transitions (such as interactive swipe-back on iOS), uses the native header bar, and consumes less memory. The regular @react-navigation/stack offers more flexibility for customizing nonstandard transitions in JavaScript, at the cost of performance.
Code example
import { createNativeStackNavigator } from "@react-navigation/native-stack";
const Stack = createNativeStackNavigator();
function AppNavigation() {
return (
<Stack.Navigator screenOptions={{ headerBackButtonDisplayMode: "minimal" }}>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Details" component={DetailsScreen} />
</Stack.Navigator>
);
}Common mistakes
- Using the classic JS-based Stack Navigator in modern apps without needing unusual customizations, which can make transitions sluggish.
Follow-up questions
- What strategies improve memory use and prevent screens from accumulating in the Navigation Stack (memory pressure)?
- How do you customize the top navigation header while preserving native performance?