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

163
Vistas
How to read data from Firebase Real Time database with React Native?

I have a really simple problem, that when I try to read data from the FireBase database, with the following code I get this error: "TypeError: ref is not a function" . I dig trough a lot of documentation and they all use it like this, but I do not have a function like that for my ref variable. I want to query all the animal names for a user ('AllatNev').

import { getDatabase, ref, set } from 'firebase/database';

const db = getDatabase();
const user_ref = ref(db, auth.currentUser.uid); //This returns my db and the userID
const query = user_ref.child("AllatNev")        //This fails with "no child function"
console.log(query)

I can easily write data with this code:

  const reference = ref(db, auth.currentUser.uid +"/"+allatid);
  set(reference, {
    'AllatNev': AllatNev,
    'AllatFaj': valueFaj,
    'AllatFajta': AllatFajta,
    'AllatSzin': AllatSzin,
    'AllatNem': valueNem,
    'AllatSzul': dateText
  });

My data looks like this:

{
  "Gkmo3hhjNaZJ8yzjHcLKAyA3Op12" : {
    "allatid1041301e703d1" : {
      "AllatFaj" : "macska",
      "AllatFajta" : "Egyiptomi",
      "AllatNem" : "szuka",
      "AllatNev" : "Zolika",
      "AllatSzin" : "Fekete",
      "AllatSzul" : "2020-4-18"
    },
    "allatid53ba6d927a183" : {
      "AllatFaj" : "kutya",
      "AllatFajta" : "Border Collie",
      "AllatNem" : "kan",
      "AllatNev" : "Grafit",
      "AllatSzin" : "Kék",
      "AllatSzul" : "2016-4-18"
    }
  }
}
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

This code can't work as you're using v8 syntax:

const query = user_ref.child("AllatNev")

Since you're using SDK version 9 or later, you should also use the syntax for that version to get the child node:

const query = child(user_ref, "AllatNev")

I always keep the list of v9 database functions handy when working on code like this, as it's the fastest way to find syntax problems like this.

about 4 years ago · Santiago Trujillo 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