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

Expose Firestore query errors #12

Closed
sampl opened this issue Apr 13, 2018 · 3 comments
Closed

Expose Firestore query errors #12

sampl opened this issue Apr 13, 2018 · 3 comments

Comments

@sampl
Copy link
Contributor

sampl commented Apr 13, 2018

First of all, thanks for releasing react-firestore. It's the perfect way to bring my two favorite tools together, and the API you chose is spot on.

A feature request: it would be great if each component could pass Firebase errors when they occur. This can happen if you try to query content but don't have the right permissions, for example.

Something like:

<FirestoreCollection
  path="stories"
  sort="publishedDate:desc,authorName"
  render={({ isLoading, data, error }) => {
    if (error) return `Whoops! ${error.message}`
    
    return isLoading ? (
      <Loading />
    ) : (
      <div>
        <h1>Stories</h1>
        <ul>
          {data.map(story => (
            <li key={story.id}>
              {story.title} - {story.authorName}
            </li>
          ))}
        </ul>
      </div>
    );
  }}
/>

I've built something similar here: https://github.com/sampl/firefly/blob/master/src/data/PostsProvider.js

@green-arrow
Copy link
Owner

@sampl - I think this is a good idea. I'll try to get to this sometime this week. Feel free to submit a PR if you want / have time 😄

@sampl
Copy link
Contributor Author

sampl commented Apr 16, 2018

Woohoo, thank you! I'll work on #14 first and check back.

@sampl
Copy link
Contributor Author

sampl commented Jun 2, 2018

@green-arrow I got this far: https://github.com/sampl/react-firestore/commit/55bdb23e38751379a86246a6e9b1b1e4f0714a98

It works, but existing tests aren't passing (and there are no new tests to cover error use cases).

To be honest, as someone new to writing tests, I think I've gotten this as far I can. If anyone can help me finish it off, I'd really appreciate it!

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