nandorojo / swr-firestore

Implement Vercel's useSWR for querying Firestore in React/React Native/Expo apps. 👩‍🚒🔥
MIT License
777 stars 65 forks source link

Compound queries #42

Closed wobsoriano closed 4 years ago

wobsoriano commented 4 years ago

Hi, awesome lib!

I am using it with RN with some geohashing like this:

  const { data } = useCollection<IBusiness>('businesses', {
    where: [
      ['geohash', '>=', range.lower],
      ['geohash', '<=', range.upper],
    ],
  });

But when I add 1 more where item, I get too many rerenders error and sometimes undefined.

  const { data } = useCollection<IBusiness>('businesses', {
    where: [
      ['geohash', '>=', range.lower],
      ['geohash', '<=', range.upper],
      ['type', '==', 'Delivery'],
    ],
  });

Am I doing it correctly or am I missing something?

nandorojo commented 4 years ago

What's the error? Does firestore allow this query? You probably have to make a custom index if it does, which isn't related to this library in particular.

wobsoriano commented 4 years ago

What's the error? Does firestore allow this query? You probably have to make a custom index if it does, which isn't related to this library in particular.

You are right, I need index for this. Weird that it doesn't throw any index errors. In RN it throws too many rerender error. In Web it's just undefined without any error.

nandorojo commented 4 years ago

That is odd, but glad we found the problem!