LOG [ReferenceError: Property ‘firebase’ doesn’t exist]
I didn’t change anything in my code but all of a sudden, when I try to create a user, using firebase’s authentication, it says property ‘firebase’ doesn’t exist. The promise doesn’t kick in after creating the user. What can I do?
const signUp = async () => {
await getDocs(createdUserDoc)
.then((user) => {
if(user.convoCode === convoCode){
setConvoCode(Math.random().toString(36).slice(6))
}
})
await auth.createUserWithEmailAndPassword(email, password)
.then(createdUser => {
setDoc(doc(db, `users`, auth.currentUser.uid), {
email,
convoCode,
id: createdUser.user.uid,
timestamp: firebase.firestore.FieldValue.serverTimestamp(),
bio: "I don't got a bio🥱",
image: 'https://firebasestorage.googleapis.com/v0/b/convoapp-91392.appspot.com/o/4112f225-1b3f-47a3-b2eb-d2b99dfd3996.jpg?alt=media&token=5c8177f3-51f7-4d77-a761-ef6b5c6ce1a0',
})
router.push('/authentication/AddUsernameScreen')
setPassword('')
setEmail('')
})
.catch((err) => {
toastRef.current.show({
type: 'error',
text: `${err.message}`,
duration: 5000
})
console.log(err)
return;
})
}
I’ve tried rolling back my code to days before today, but it still gives the same thing. I don’t know what to do because I didn’t change anything in my code. And I’m under pressure to push the update over the weekend
2
Answers
You’re mixing the newer modular API and the classic namespaced API in your access to Firestore.
Based on that, the error likely comes from this line:
In the modular API, you need to import the top-level
serverTimestamp
function from the Firestore SDK and then use it as:To close out this topic, there were a couple of issues with the initial post. We moved to this discussion.
Summary:
async/await
and.then()/.catch()
; recommended to just useasync/await
react-native-firebase
andfirebase
in the same Expo/RN app ; recommended just usingreact-native-firebase
; detailed explanation of the options is here.getDocs()
was not using return value correctly@mac concluded that he will refactor the code taking into account all of the above.