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

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

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