Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

420
Views
React Native: bottom tab press not working

in my react-native app I have a bottom tabs navigation, I added a tabPress listener to one of the screens but for some reason now all screens don't work, I can't navigate to a different screen when I tap the icons...

The objective was to lock a screen depending of the day but now ALL screens are locked for some reason and I can't navigate to ANY screen!

<Tab.Navigator /* options here... */>
        <Tab.Screen name="Descubre" component={STACK1} />
        <Tab.Screen name="Favoritos" component={STACK2} 
        listeners={{
          tabPress: (e) => {
              if(root.mapStore.isoWeekDay == 6)
              {
                e.preventDefault();
              }
          },
        }}
        />
        <Tab.Screen name="Pedidos" component={STACK3} />
        <Tab.Screen name="Más" component={STACK4}/>
    </Tab.Navigator>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I'm guessing this is the default behaviour stablished by React Native for this event, check section Listening to events​

If you want only to block one of the screens in this point, you could do the following:

<Tab.Navigator>
<Tab.Screen name="Screen 1" />
<Tab.Screen name="Screen 2"
    options={{
        tabBarButton: disabled ? DisabledTabBarButton : EnabledTabBarButton,
    }}
/>
</Tab.Navigator>

Where DisabledTabBarButton is:

const DisabledTabBarButton = ({ style, ...props }: BottomTabBarButtonProps) => (
    <Pressable disabled style={[{ opacity: 0.2 }, style]} {...props} />
)

And enabled one:

const EnabledTabBarButton = ({ style, ...props }: BottomTabBarButtonProps) => (
    <Pressable style={[{ opacity: 1 }, style]} {...props} />
)

Also, you could do the following while creating your tab navigator:

const TabNavigator = createBottomTabNavigator({
First:{
    screen: First,
},
Second:{
    screen: Second,
},
Third:{
    screen: Third,
}
}, defaultNavigationOptions: ({ navigation }) => ({
  tabBarOnPress: ({ navigation, defaultHandler }) => {
    if (
      navigation.state.routeName === "Route disabled"
    ) {
      return null;
    }
    defaultHandler();
  },})
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!