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

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

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 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