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

383
Vistas
How to read firestore data in react native?

Hello I am new to react native and particullary firebase. I've been watching tutorial about using firebase with react native and i read the react native firebase documentation but i am stuck. I have data in my firestore data base, in my collection called user but I am not able to read, to get the data from it. Here is my firestore database : Here is my firestore database

and here is how I tried to get the data in my component :

const Profile = ({navigation, ...props}) => {



    async function getUserData () {
        const userCollection = await await firebase.firestore().collection('users').doc(firebase.auth().currentUser.uid).get()
        return userCollection
    }
    console.log('🐲' + getUserData())

this return me that : [object Object]

I also tried this, (it was how it was done in the instagram clone tutorial of Adrian Twarog) :

const Profile = ({navigation, ...props}) => {

  function getUserDataFirstTry() {
        firebase.firestore()
        .collection("users")
        .doc(firebase.auth().currentUser.uid)
        .get()
        .then((snapchot) => {
            if(snapchot.exists){
                console.log('🦜' +  snapchot.data())
            } else {
                console.log('merde ca marche pas')
            }
        })
    }

    console.log('🐲🐲' + getUserDataFirstTry())

But I get the same result in my console : [object Object]

I tried to put my function in a useEffect hook but this changes nothing. Can you tell me what I am doing wrong ? (if possible in the second example because it's realtime changes). Thanks.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

As Nicholas commented, since you're concatenating snapchot.data() to a string, you get the string representation of that object, which is pretty useless.

To log a specific field from the data:

console.log('🦜' +  snapchot.data().userName)

To log all fields from the data in a more useful format:

console.log('🦜' +  JSON.stringify(snapchot.data()))

Note: the proper spelling is snapshot (not snapchot), but I kept your original spelling here for ease of copy/paste.

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