Technologies:
Tolerim
a day ago
Fix the issue of unexpected navigation to another page while navigating by implementing a sticky header and tab bar in React Native Navigation.
return (
<ScreenTemplate>
<Header stack={getFocusedRouteNameFromRoute(useRoute())} />
<Tab.Navigator
initialRouteName="HomeTab"
tabBarPosition="bottom"
screenOptions={{
...
return (
...
<View style={[styles.column, { justifyContent: 'flex-end' }]}>
{stuff}
<IconButton
icon="bell"
color={theme.primary}
size={24}
// @ts-expect-error TS(2769): No overload matches this call.
onPress={() => navigation.navigate('Notification')}
containerStyle={{ paddingRight: 15 }}
/>
</View>
</View>
)
}
Answers(1)
Tolerim
a day ago
Verified Answer
Unfortunately, the question doesn't seem to be related to JavaScript or JavaScript libraries. It's more of a React Navigation issue specific to the implementation of the app in question. However, the issue seems to be related to the navigation.navigate('Notification') method in the IconButton component, which is not grabbing the proper stack to navigate in, causing the app to jump to a different page before going to the notification screen. A possible solution would be to make sure the stack name is properly passed to the Header component and used in the navigation.navigate() method to navigate to the notification screen within the correct stack. It's also worth checking the navigation stack and routes to make sure they are properly set up. Without more information or code snippets, it's hard to give a more specific solution.