Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

263
Vistas
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 Respuestas
Responde la pregunta

0

Please try this

  headerLeft: ({onPress}) => (
              <TouchableOpacity onPress={onPress}>
               {...}
              </TouchableOpacity>
            )
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda