I created this simple React Native app from scratch but I am having trouble getting simple stacked navigation to work. I don't get any console exception but what happens is the page doesn't change. It still renders the same home component.
Setup:
export default function Index() {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="Home">
<Stack.Screen
name="Home"
component={Home} options={{
title: "overview"
}} />
<Stack.Screen name="About" component={About} />
</Stack.Navigator>
</NavigationContainer>
);
}
Home component:
export function Home() {
return (
<View style={styles.container}>
<Text>Welcome!</Text>
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home Screen</Text>
<Button
title="Go to About"
onPress={() => {
navigation.navigate('About')
}}
/>
</View>
</View>
);
}
Initial page:
After clicking on go to about page:

