I'm trying to use react navigation. But when I click on the button to navigate, nothing happens. I'm new to React Native.
App.js:
function App() {
const Stack = createStackNavigator();
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Details" component={DetailsScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
HomeScreen.js
function HomeScreen({ navigation }) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>HomeScreen Screen</Text>
<Button
title="Go to Detail"
onPress={() => navigation.navigate('Details')}
/>
</View>
);
}
DetailScreen.js:
function DetailsScreen() {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Details Screen</Text>
</View>
);
}
When I click in "GO TO DETAIL" nothings happends
What can be the problem?
EDIT: I think that the problem could be from the emulator, maybe I dont "click" correctly on the button