1

I have a main bottom tabs navigator in my app which contains three screens and every one of these pages contains a stack navigator. The problem is, whenever i press The icon in bottom tab when it is focused, the stack will go back to the first page of its corresponding stack navigator. I don't want that to happen in my LoanNavigator screen. But it's ok to happen in other screens. How can i achieve this? Here's how my code looks like:
MainBottomTabsNavigator.jsx

return (
        <TabBarContext.Provider value={{ props: tabBarProps, setProps: setTabBarProps }}>
            <Tab.Navigator initialRouteName='loan'>
                <Tab.Screen name="settings" component={SettingsStackNavigator}
                <Tab.Screen name="loan" component={LoanStackNavigator} />
                <Tab.Screen name="wallet" component={WalletStackNavigator}
            </Tab.Navigator>
        </TabBarContext.Provider>
    )

LoanNavigator.jsx

return (
        <Stack.Navigator>
            <Stack.Screen name="calculator" component={Loan.Calculator} />
            <Stack.Screen name="confirmation-modal" component={Loan.ConfirmationModal} options={{ 
                presentation: 'modal',
                detachPreviousScreen: false,
                cardStyle: { backgroundColor: 'transparent' }
             }} />
            <Stack.Screen name="choose-shop" component={Loan.ChooseShop} />
            <Stack.Screen name="deposit" component={Loan.Deposit} />
        </Stack.Navigator>
    )
Ardalan
  • 723
  • 9
  • 26

1 Answers1

0

You can find how to have your own custom implmenation from the documentation.

You can do so like this:

<Tab.Navigator tabBar={(props) => <MyTabBar {...props} />}>

Simplified working example: https://snack.expo.dev/@tnr_c/custombottab

TnR
  • 99
  • 4
  • Actually, i do have my own custom implementation of tab bar (because i had to render the tab bar somewhere else too). But i've been looking for an official way of doing that, which there is no official way apparently. – Ardalan Dec 23 '21 at 16:55
  • I would say its the official way since its documented as such. – TnR Dec 23 '21 at 18:21