Home > Software design >  Firebase React Native: TypeError: Cannot call a class as a function
Firebase React Native: TypeError: Cannot call a class as a function

Time:08-02

I have this error: [TypeError: Cannot call a class as a function]. I'm trying to update my user information in firestore and show an alert when done. When I click the button "save" it updates the information inside the firestore but it shows an error in the console.

OnPress Activity on TouchableOpacity:

onPress={async () => {
                            const updatedUser = await firestore()
                                .collection('Users')
                                .doc(currentUser.uid)
                                .update({
                                    'name': name,
                                })
                                .then(() => {
                                    Alert("Successfully updated!")
                                })
                                .catch((e) => {
                                    console.log(e);
                                });
                        }}

I've seen people have this error when they're trying to add GeoLocation, but I'm just trying to update user's name. I tried to do it outside of the onPress, not working.

CodePudding user response:

As far as I can tell from the Alert documentation, you have to invoke it like this:

Alert.alert("Successfully updated!", "")
  • Related