FirebaseExtended / FirebaseExtended/reactfire
Infinite request loop in useFirestoreCollection
- 主要语言
- TypeScript
- 星标
- 3.6k
- 派生
- 403
- 平均合并
- 14 小时 53 分钟
- 30 天内合并 PR
- 5
描述
Hello,
the following code results in an infinite loop when user isn't authenticated aka `user.data` is `undefined`. Is this expected?
```
const user = useUser(undefined, { suspense: true });
const subscriptions = useFirestoreCollection(
firestore
.collection('customers')
.doc(user.data?.uid)
.collection('subscriptions')
```
When something random and non-existent is passed to `doc(myId)`, it throws `Missing or insufficient permissions`, when `null` is passed it throws `Function CollectionReference.doc() cannot be called with an empty path`, however when `undefined` is passed the code goes into an infinite loop and triggers hundreds of requests per second.
贡献指南
调研方向
Reproduce the issue with the shown useUser and useFirestoreCollection snippet, then trace how useFirestoreCollection handles an undefined document path. Compare its behavior with null and a nonexistent id; done means the undefined case no longer causes repeated requests and has a defined outcome.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- firebase, react, typescript
- 领域
- databases, frontend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100