2

I have two main screens:

  • FIRST (with Bottom Bar contains 3 tabs)
  • SECOND (standard new screen)

How to make clicking the button in BottomTabBar opens a new screen?

By default, the buttons in Bottom Bar open a new tab. I would like one button to open a whole new screen

Just like it is on the screen

enter image description here

Screen code with Tab (3 elements):

function App() {
  return (
    <NavigationContainer>
      <Tab.Navigator tabBarOptions={{
        showLabel: true,
        style: {
          backgroundColor: 'transparent',
          position: 'absolute',
          borderTopWidth: 0,
          elevation: 0,
        }
      }}>
        <Tab.Screen name="Home" component={Home}/>
        <Tab.Screen name="Second" component={Second}/>
        <Tab.Screen name="Other" component={Other} />
      </Tab.Navigator>
    </NavigationContainer>
  );
}
DeveloperApps
  • 763
  • 7
  • 16

1 Answers1

1

You may try this:

<Tab.Screen
        options={({navigation}) => ({
            tabBarButton: props => 
                <TouchableOpacity {...props} onPress={() => navigation.navigate('YourScreen')} />
        })}
        name="Second" component={Second}
/>

You can navigate to new screen if that screen is not included in your bottom tab :)

You can find more in here: https://reactnavigation.org/docs/bottom-tab-navigator#tabbarbutton

Hope that help :)

Brian H.
  • 1,603
  • 11
  • 16