rakannimer/react-firebase

FirestoreCollection doesn't refetch when props changed

isotopeee opened this issue · 0 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