rakannimer / react-firebase

🔥Declarative React bindings for Firebase Auth & Realtime Database.

Home Page:https://react-firebase-js.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FirestoreCollection doesn't refetch when props changed

isotopeee opened this issue · comments

Hi,

thanks for this library

I've noticed that even when the where props of the FirestoreCollection changes, it doesn't try to re-fetch, I'm not sure if that's intended. It seems that the fetching only happens on FirestoreCollection mount and doesn't happen on re-renders.

If that's an expected behavior, is there a way to trigger a re-fetch on an existing (mounted) FirestoreCollection? Is there something like the refetch prop of react-apollo's Query component?

My code looks something like this, and I'm very sure that the search props it receives changes:

export function Connector(props: PatientListConnectorProps) {
  const { search } = props;

  return (
    <FirestoreCollection
      path="/entity"
      where={
        search
          ? {
              field: 'name',
              operator: '==',
              value: search,
            }
          : null
      }
    >
      {({ isLoading, value }) =>
        props.children({
          fetcher: {
            isLoading: isLoading,
            patients: value,
          },
        })
      }
    </FirestoreCollection>
  );
}

Thank you in advance