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

117
Vistas
undefined is not an object (evaluating 'navigation.reset')

I was thinking that my code was right, but it turned out that it gave me undefined, however when i click a button to go to 'List'; it works! it just i can't do it from TouchableOpacity onPress. Here's my code

import { StyleSheet, Text, View,TouchableOpacity } from 'react-native'
import {useSelector, useDispatch} from 'react-redux'
import {fetchDogsAsync} from '../store/action/index'

const DogsList = ({navigation}) => {
    const dispatch = useDispatch()
    const {dogs,isLoading} = useSelector(state => state)
    useEffect(() => {
        dispatch(fetchDogsAsync())
    }, [dispatch])
    console.log(dogs,isLoading);
    return (
        <View>
        {
                isLoading ? <Text>Loading...</Text> : (dogs?.message).map((dog,idx)=> {
                    return (
                        <TouchableOpacity key={dog} onPress={() => navigation.reset({
                            index: 0,
                            routes: [{name: 'List', params: {breed: dog}}],
                          })}><Text>{dog}</Text></TouchableOpacity>
                    )

                })
            }
    </View>
    )
}

export default DogsList

const styles = StyleSheet.create({})
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

<Navigator.Screen
     name="initial"
     component={ListScreen}
     options={{ title: "", headerShown: false }}
/>

only the components used in Screen tags will receive the navigation prop. Here ListScreen will receive the navigation prop. However the child components of ListScreen won't receive the navigation prop. But you can use useNavigation hook anywhere in the component tree which will give you the navigation object. You can read more about it in their official documentation.

https://reactnavigation.org/docs/use-navigation/

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