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

96
Visualizações
undefined is not an object (evaluating 'snapshot.data().newUser') when navigating to Screen

I use componentDidMount to start fetchNewUser when I navigate to the screen, it is supposed to recognize a new user and update it if it true, the problem is that when I navigate in the screen for the first time it returns undefined is not an object (evaluating 'snapshot.data().newUser'), but if I refresh the screen it works.

  fetchNewUser = async () => {
        const fetchInformation = doc(db, 'path')
        await getDoc(fetchInformation)
        .then( async (snapshot) => {
          const newUser = await snapshot.data().newUser
          const address = await snapshot.data().mainAddress
          console.log(newUser)
          if (newUser == true || newUser == undefined) {
            this.props.navigation.navigate('AddressSearch')
            updateDoc(fetchInformation, {
                newUser: false
              })
          } else {
            this.setState({address: address})
          }
        })
        .catch((err) => console.log(err))
      }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The problem is that you are trying to acces newUser on the promise, what you should do instead is const newUser = (await snapshot.data()).newUser

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