I am trying to navigate to my (tabs)/index.tsx screen from a different screen outside of the (tabs) folder on the web version of my app. It works fine on mobile. I have tried importing HomeScreen from (tabs)/index.tsx and then navigating to it, but that didn’t work. I have also tried going specifically to (tabs)/index.tsx but that failed as well.
The code snippet with first attempt:
import HomeScreen from './(tabs)/index';
//other code
const handleContinue = () => {
if (Platform.OS === "web") {
window.location.href = `${HomeScreen}?selectedTopics=${encodeURIComponent(JSON.stringify(selectedTopics))}`;
} else {
navigation.navigate('tabs', { screen: 'Home', params: { selectedTopics } });
}
};
Then the code snippet for the second attempt:
const handleContinue = () => {
if (Platform.OS === "web") {
window.location.href = `/(tabs)/index?selectedTopics=${encodeURIComponent(JSON.stringify(selectedTopics))}`;
} else {
navigation.navigate('tabs', { screen: 'Home', params: { selectedTopics } });
}
};
When I try both of these, I get “This screen doesn’t exist”. What can I do to fix this problem?