Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Disabling queries via ReactFireOptions

未关闭
#346 1 条评论 8 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
firebase, react, typescript
领域
frontend

调研方向

该 issue 将 ReactFireOptions 和 ObservableStatus 列为相关入口;首先跟踪 ReactFire hooks 如何执行查询并暴露 status。将提议的 enabled 行为与替代的 exists status 进行比较,包括 initialData 的处理。完成的标准是:依赖查询可以避免意外执行,或能够可靠地确定引用是否存在,而不会将占位数据当作结果。

由索引模型根据 Issue 内容生成。

描述

v5

I've read the discussion in #178 and am yet another person that has run into the wall of "can't use the hooks with a not-yet-defined id". I understand and agree with your desire to keep undefined/null ids as errors. But we still run into situations where the use of react-fire hooks constrains our design decisions and requires us to make several small components that issue the same query when one query would do and would allow us to present the UI in a single component as we wish.

I suggest adopting something similar to how react-query handles this. Passing in an enabled flag to the ReactFireOptions object which would prevent the query from executing if enabled === false (and instead returning initialData, if defined). This would allow the errors to persist when inadvertently passing in undefined/null, but also allow consumers to make their own design decisions when constructing dependent queries.

Alternatively, add an exists property to the ObservableStatus so that we can determine, without an additional query, whether the ref already exists. Currently when I have a dependent query I pass in an ID that I know not to exist, e.g. "-1", but I get back a document that has a firestore-generated ID and nothing else. Without the ability to disable the query or determine if the ref exists I rely on the object being otherwise empty to determine if I should return an undefined or not.

主要语言
TypeScript
星标
3.6k
派生
403
平均合并
5 天 1 小时
30 天内合并 PR
10

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

FirebaseExtended/reactfire 的其他 Issue

查看 FirebaseExtended/reactfire 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。