FirebaseExtended / FirebaseExtended/reactfire

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

オープン
#192 コメント 8 件 リアクション 2 件 担当者 1 名 @jhuleatt が担当を希望しています GitHub で見る
needs investigation v5
主要言語
TypeScript
スター
3.6k
フォーク
403
平均マージ
14時間 53分
マージ済み PR(30日)
5

説明

### 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.

```ts
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(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'

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。