Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get an error when using snapshot listener #84

Open
Yahirrro opened this issue Jan 12, 2021 · 3 comments
Open

Unable to get an error when using snapshot listener #84

Yahirrro opened this issue Jan 12, 2021 · 3 comments

Comments

@Yahirrro
Copy link

I am using this package to get Firestore documents in real time using a snapshot listener.

In the process, I want to show an error screen when permissions are missing or the document is not available, but I noticed that I cannot get the error using the documentation method.

I would like to know how to solve this.

const { data: quiz, error: errorQuiz } = useDocument<QuizModel>(
  props.params.quizId ? `quiz/${props.params.quizId}` : null,
  {
    listen: true,
  }
)

if (errorQuiz) return <ScreenError code={404} />

The error is output to the console, but the error remains undefined.

image

@nandorojo
Copy link
Owner

This isn't really a case that should happen with Firestore permissions. I recommend using states to only show screens/calls to people who have permissions to view them.

@Yahirrro
Copy link
Author

I think so too.
However, I think the problem is that I can't display an error when a user accesses a document that doesn't exist.

I can't get the error only when the listener is enabled, is the correct behavior?

@nandorojo
Copy link
Owner

I see.

It looks like adding error handing for listeners would be its own feature addition.

https://firebase.google.com/docs/firestore/query-data/listen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants