Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

277
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!