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

useFirestoreDocData & useFirestoreDoc won't throw a promise on permission denied

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

@jhuleatt 已经在做这个了。

开始于 2019年12月10日。

评估

这个 Issue 还没有评估数据。

描述

needs investigation v5
Version info

React: 16.12.0

Firebase: 7.5.2

ReactFire: 2.0.0-canary.1fce6b9

Test case

I want to use role based authentication on documents, so when a document is successfully read in the app and then I change the access of that user, the listener throws an error instead of a Promise.

const CompanyCheck: React.FC = ({ children }) => {
  const { companyId, setCompany } = useCompanyContext();

  const firestore: Firebase['Firestore'] = useFirestore();

  const companyRef = useRef(
    firestore()
      .collection('companies')
      .doc(companyId)
  );

  useEffect(() => {
    companyRef.current = firestore()
      .collection('companies')
      .doc(companyId);
  }, [companyId, firestore]);

  // This won't throw a promise on permission changes after successfull read.
  const companyDoc = useFirestoreDocData<Company>(companyRef.current);

  useEffect(() => {
    setCompany(companyDoc);
  }, [companyDoc, setCompany]);

  return <>{children}</>;
};
Steps to reproduce

Use a correct example of read operation with role access, then once the data is displayed remove the access to the document and error boundary won't catch any error.

Expected behavior

Throw a promise like when initial read fails so ErrorBoundary can catch the error.

Actual behavior

Don't throw a Promise and error can't be handled. Error message is: 'permission-denied'

主要语言
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 摘要。