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

279
Vistas
firebase.database is not a function why I am getting this error in react native app?

I am getting this error when I tried to fetch data from Firebase realtime database-

AboutApp.js:9 Uncaught TypeError: config__WEBPACK_IMPORTED_MODULE_9_.firebase.database is not a function at AboutApp.js:9:1

Is there anything wrong on my code?

Please check the database structure

enter image description here

import React, { useState, useEffect } from 'react';
import {View, Button, Text, FlatList, StyleSheet, Pressable, TouchableOpacity} from 'react-native'
import {firebase} from '../config';


const AboutApp = ({ navigation }) =>{
const [users, setUsers] = useState([]);
useEffect(() => {
 const users = firebase.database().ref("first");
 users.on("value",datasnap=>{
    console.log(datasnap.val());
 });
 setUsers(users)

}, [])


    return (
       <View style={{ flex:1, marginTop: 100}}>
           <FlatList
           style={{height: '100%'}}
           data={users}
           numColumns={1}
           renderItem={({item}) => (
             <Pressable
         style={styles.container}>
         <View style={styles.innerContainer}>
             <Text>{item.name}</Text>
             <Text>{item.email}</Text>
             <Text>{item.phone}</Text>
             
         </View>
         
             </Pressable>
           )}
           />
            </View>
         );
         
         }
    export default AboutApp; 

Please check the config file-

import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore'


const firebaseConfig = {
  apiKey: "AIzaSyBS93aTCkwMyEWU15HR5y454qZM_WTDXhAo",
  authDomain: "newawesome-18ee9.firebaseapp.com",
  projectId: "newawesome-18ee9",
  storageBucket: "newawesome-18ee9.appspot.com",
  messagingSenderId: "441185679151",
  appId: "1:441187374121:web:ecf6de832274a4480b8610",
  measurementId: "G-R6NM36814P"
};

if (!firebase.apps.length){
    firebase.initializeApp(firebaseConfig)
}
export {firebase};
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It seems you are trying to use Firebase Realtime Database and not Firestore. You are not importing the RTDB SDK. Try adding the following import:

import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore'

import 'firebase/compat/database' // <-- Import RTDB SDK

Also, Firebase will be removing the "compat" SDK in future updates so it'll be best to upgrade your code to the new Modular SDK. Checkout the documentation for more information.

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