React-native-firebase: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()

Created on 22 Mar 2020  路  2Comments  路  Source: invertase/react-native-firebase

It happens when it calls database().ref()

Screenshot_1584898100

`import React, { Component } from 'react';

import {
StyleSheet,
Text,
View,
TouchableOpacity,
Image,
FlatList,
StatusBar,
TextInput,
Alert,
SafeAreaView,
} from 'react-native';

//import react in our code.
import database, { firebase } from '@react-native-firebase/database';

//import all the components we are going to use.

const options = {
title: 'Select Image',
storageOptions: {
skipBackup: true,
path: 'images'
}
};
const ImageRow = ({ image, windowWidth, popImage }) => (

source={{ uri: image }}
style={[styles.img, { width: windowWidth / 2 - 15 }]}
onError={popImage}
/>

);
export default class RegisteredCaseScreen extends Component {
state = {
imgSource: '',
uploading: false,
progress: 0,
images: [],
isAuthenticated: false,
isLoading: false,
country: '',
city: '',
cState:'',
area:'',
patientsArr:[],
height: 0,
width: 0
};
componentDidMount() {

}
/**

  • Select image method
    */
    pickImage = () => {
const db_ref = database().ref(`/patients`+"/"+this.state.country+"/"+this.state.cState+"/"+this.state.city+"/"+this.state.area);
db_ref.once('value', function(snap){
  resultSet = [];
  console.log("\n\n\n\n"+`/patients`+"/"+this.state.country+"/"+this.state.cState+"/"+this.state.city+"/"+this.state.area);
  snap.forEach(function(countryObj){
    if(countryObj.val().area==undefined)
    {......... `
No Template

All 2 comments

You did not follow the template, it's hard to say why your project isn't working.
As a quick check before trying again with full information, you might try cloning this repo, and running this script: https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh - it will generate a complete + functioning throwaway demo and you can try putting your db code in there to see if it works. If it does then the difference will be found by comparing it's output with your project

Thank you very much for the quick answer, I created a new example project but it keeps going wrong

Was this page helpful?
0 / 5 - 0 ratings