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

262
Visualizações
this.props.navigation.goBack() is undefine and doesnt push back in React Native

I was trying to call the this.props.navigation.goBack() function after I modified the headerLeft icon:

const Stack = createStackNavigator();

class App extends Component {
  render() {
    return (
        <NavigationContainer>
          <Stack.Navigator
            initialRouteName={'VideoList'}
            screenOptions={{
              headerBackTitleVisible: false,
            }}>
            <Stack.Screen
              name="Video Details"
              component={VideoDetails}
              options={{
                headerBackTitleVisible: false,
                headerLeft: ({focused}) => (
                  <TouchableOpacity onPress={this.props.navigation.goBack()}>
                    <Image
                      source={icons.back}
                      resizeMode="contain"
                      style={{
                        width: 15,
                        height: 15,
                        marginLeft: 20,
                        tintColor: focused ? COLORS.primary : COLORS.secondary,
                      }}
                    />
                  </TouchableOpacity>
                ),
              }}
            />
          </Stack.Navigator>
        </NavigationContainer>
    );
  }
}

As you can see I am using an image to replace the headerLeft, however upon clicking the button via TouchableOpacity it doesn't redirect me to the previous screen. The back button doesnt push back using this.props.navigation.goBack();

Any idea how to fix this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Please try this

  headerLeft: ({onPress}) => (
              <TouchableOpacity onPress={onPress}>
               {...}
              </TouchableOpacity>
            )
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