Reputation: 1
I'm using react navigate V6 and I want to move between stacks , but this code is not working :
navigation.navigate("Stack Name", { screen: "screen Name" });
@react-navigation/native
is not working with V6
Upvotes: 0
Views: 1054
Reputation: 297
work for me
import { createStackNavigator } from '@react-navigation/stack';
const MyStack = createStackNavigator();
const SettingsStack = createStackNavigator();
function HomeStackScreen() {
return (
<MyStack.Navigator>
<MyStack.Screen name="Home" component={HomeScreen} />
<MyStack.Screen name="Details" component={DetailsScreen} />
</MyStack.Navigator>
);
}
function SettingsStackScreen() {
return (
<SettingsStack.Navigator>
<SettingsStack.Screen name="Settings" component={SettingsScreen} />
<SettingsStack.Screen name="Profile" component={ProfileScreen} />
</SettingsStack.Navigator>
);
}
import { useNavigation } from '@react-navigation/native';
function HomeScreen() {
const navigation = useNavigation();
const handlePress = () => {
navigation.navigate('Settings', { screen: 'Profile' });
};
return (
<Button title="Go to Profile" onPress={handlePress} />
);
}
Upvotes: 0