I'm currently working on an app in which you can keep track of Root Canal patients and it was working fine for a long time...but after the new update of the firebase
package in expo...I've been getting an error while trying to sign up. It says "Attempted to assign to readonly property" but my cloud firestore rules are set so that it is allowed. So, I am not too sure about what I did wrong.
This is the firestore rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if
request.time < timestamp.date(2023, 12, 31);
}
}
}
This is the code for the sign up function:
onSignUp = async (email, password) => {
firebase // used import * as firebase from 'firebase/auth'
.createUserWithEmailAndPassword(
this.state.modalEmail,
this.state.modalPassword
)
.then(() => {
firestore // used import * as firestore from 'firebase/firestore'
.collection("Users")
.doc(this.state.modalEmail)
.set({
username: this.state.username,
email_id: this.state.modalEmail,
clinicName: this.state.clinicName,
age: this.state.age,
phoneNumber: this.state.phoneNumber,
tablets: []
});
this.setState({ isModalVisible: false });
this.props.navigation.replace("Home");
})
.catch((error) => {
Alert.alert("Coudn't create user", error.message);
console.log(error)
});
};
the error I'm getting:
If you have any idea on what I did wrong or what I could do to fix this issue please let me know. Thanks in advance!
If your using firebase 9, the signature is changed. the auth object needs to be passed as first parameter.
const auth = getAuth();
createUserWithEmailAndPassword(auth, email, password)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.