I am getting the following error when uploading an image to Firebase:
Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
Here is my code:
App.js
import * as Firebase from 'firebase'; componentDidMount() { Firebase.initializeApp(firebaseConfig); }
Profile.js
import * as Firebase from 'firebase'; import rnFb from '@react-native-firebase/storage'; uploadImage = localUri => new Promise((resolve, reject) => { const localUri2 = Platform.OS === 'ios' ? localUri.replace('file://', '') : localUri; const fbUri = Firebase.storage().ref(); rnFb().ref(localUri2).putFile(fbUri) .then( () => { resolve(); } ) .catch( (e) => { reject(e); } ); });
It's failing at the .putFile
line.
I don't understand what the problem is because I am calling .initializeApp()
in App.js
UPDATE 12/21
I added console.log(Firebase.apps.length);
right before rnFb().ref(localUri2).putFile(fbUri)
and the output is 1...very strange indeed.
...and if I do exactly as the error asks and call firebase.initializeApp()
right before rnFb().ref(localUri2).putFile(fbUri)
I get the error Error:
Firebase: Firebase App named '[DEFAULT]' already exists
Help!!