Per*_*age 3 firebase google-cloud-firestore
在反应应用程序中,我在同一个文件中有两个几乎相同的函数来将文档添加到子集合中。一个每次都有效,另一个使用不同的子集合,大多数时候都会收到以下警告(注意:不是错误),并且不会添加数据。
\nawait addDoc(collection(db, 'users', uid, 'medications'), med);\nRun Code Online (Sandbox Code Playgroud)\n\n\n\xe2\x80\x8b[2022-02-16T20:54:44.216Z] @firebase/firestore: Firestore (9.6.6): 连接 WebChannel 传输错误: Vd\xc2\xa0{type: 'c', target: Y ,g:Y,defaultPrevented:false,状态:1}
\n
另一个奇怪的行为是,调用 addDoc 后,应用程序会重新导航到当前页面,但会将要添加到文档中的数据附加到 URL 中。页面中根本没有导航链接。无论是否添加数据都会发生这种情况。
\n\n\n导航到 http://localhost:3000/create?name=test+med+again&description=a+med+for+testing&form=capsule&dosage=1&measurement=ea&occurrence=2&often=daily
\n
关于 firestore Connection WebChannel 传输错误。我在尝试在 React Native 中实现简单的增删改查操作时遇到了类似的问题。我在互联网上找到的大多数解决方案都与向 firestore 初始化添加设置有关,但它们也使用 firebase v8 语法(请参阅:React Native 重复超时将集合写入 firestore@firebase/firestore: Firestore (8.4.2): Connection WebChannel 传输错误)
这种初始化 firestore 的方法在 firebase(9.8.3) 上为我解决了这个问题
const app = initializeApp(firebaseConfig);
export const db = initializeFirestore(app, {
experimentalForceLongPolling: true,
useFetchStreams: false,
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2537 次 |
| 最近记录: |