Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

418
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda