Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#192 8 commenti 2 reazioni 1 assegnatario Vedi su GitHub

@jhuleatt ci sta già lavorando.

Dal 10/12/2019.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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'

Lingua principale
TypeScript
Stelle
3.6k
Fork
403
Merge medio
5g 1h
PR unite (30g)
10

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di FirebaseExtended/reactfire

Tutte le issue di FirebaseExtended/reactfire

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.