React Native不能将类作为函数调用



我有一个简单的功能,可以在firebase中注册用户,并将数据保存在云firestore 中

但我得到了这个错误:

[TypeError:无法将类作为函数调用]

有人能帮我找到错误的位置吗?

以下功能:

const handleSignUp = useCallback(
async data => {
try {
setLoading(true);
const auth = await authFB().createUserWithEmailAndPassword(
data.email,
data.password,
);
const db = firestore();
const firstName = data.name.split(' ').slice(0, -1).join(' ');
const lastName = data.name.split(' ').slice(-1).join(' ');
await db
.collection('Providers')
.doc(auth.user.uid)
.set({
id: auth.user.uid,
name: {
first: firstName,
last: lastName,
},
email: data.email,
createdAt: firestore.Timestamp.fromDate(new Date()),
address: {
position: firestore.GeoPoint(
coordinates.latitude,
coordinates.longitude,
),
},
})
.then(() => {
navigation.reset({
routes: [{ name: 'SignIn' }],
index: 0,
});
});
setLoading(false);
Alert.alert(
'Cadastro realizado com sucesso!',
'Você já pode fazer login na aplicação.',
);
} catch (err) {
setLoading(false);
}
},
[coordinates],
);

我对Firestore API不是很熟悉,但很可能您只需要new关键字就可以创建GeoPoint:

position: new firestore.GeoPoint(
coordinates.latitude,
coordinates.longitude,
),

最新更新