useFirestoreCollection triggers a double render
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript, react
调研方向
首先使用 useFirestoreCollection 测试用例复现该行为,并将其与类似的 useUser 行为进行比较。检查这些 hook 的入口点,以确定为什么使用 Suspense 获取数据会导致 console.log 运行两次。完成的标准是:获取数据产生一次渲染,之后只有在 collection 发生变化时才会再次渲染。
由索引模型根据 Issue 内容生成。
描述
Hi,
Seems like useFirestoreCollection always triggers unnecessary render when fetching data (suspense is on). Similar behavior is also the case for useUser.
There's a chance I'm simply using the API wrong, so please advise if so :)
Version info
React: 17.0.2
Firebase: 9.1.3
ReactFire: 4.2.0
Test case
const q = /* whatever query */;
const queryResults = useFirestoreCollection(q);
console.log(queryResults);
Expected behavior
console.log is called once.
Actual behavior
console.log is called twice.
Ultimately, what I'm trying to achieve is a code similar to the one below
const queryResults = useFirestoreCollection(query);
return queryResults.data.docs.map((d) => /* render */);
that renders only once when the data is fetched (and then only when there're changes in the collection).
- 主要语言
- TypeScript
- 星标
- 3.6k
- 派生
- 403
- 平均合并
- 5 天 1 小时
- 30 天内合并 PR
- 10
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
FirebaseExtended/reactfire 的其他 Issue
-
难度 5/5 一周以上 新手友好度 38/100
FirebaseExtended/reactfire#801 ·
-
v5
难度 4/5 3-5 天 新手友好度 48/100
FirebaseExtended/reactfire#793 ·
-
v5
难度 4/5 3-5 天 新手友好度 35/100
FirebaseExtended/reactfire#790 · 2 条评论 ·
-
v5
难度 4/5 3-5 天 新手友好度 55/100
FirebaseExtended/reactfire#789 ·
-
难度 5/5 一周以上 新手友好度 35/100
FirebaseExtended/reactfire#788 ·
查看 FirebaseExtended/reactfire 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
bcgov/bc-wallet-mobile#4761 · 1 条评论 ·
-
external-issue to-triage
难度 2/5 1-3 小时 新手友好度 88/100
-
area-deployment area-integrations triage:bot-seen
难度 2/5 半天 新手友好度 86/100
-
难度 2/5 1-3 小时 新手友好度 82/100
-
refactor
难度 2/5 1-3 小时 新手友好度 84/100