我是 Expo App 和 Firebase 的新手,我正在尝试建立一个工作数据库,用户可以在其中保存多个事件。
在我的 firebaseConfig.js 中有这一行:
export const db = getFirestore(app);
我试过这个:
import { db } from "../../firebaseConfig";
export const FireBaseTest = () => {
const userRef = doc(db, "users", "KgpStI4rXjSoSXiaIMhDug2J8I92", "events");
return (
<Button
title={"test"}
onPress={async () => {
await setDoc(userRef, {
name: "test",
id: "3",
emoji: "🚙",
datetime: new Date(),
});
}}></Button>)
}
还有很多其他变体,但我只会出错。我做错了什么?