react-firebase-hooks icon indicating copy to clipboard operation
react-firebase-hooks copied to clipboard

add enabled flag for firestore

Open hussamkhatib opened this issue 2 years ago • 1 comments

fetch only if enabled is true,

Coinsider the example

  const [value, loading, error] = useDocument(
    doc(firestore, "users", useruid)
  );

adding a optional flag to fetch only when useruid is defined

  const [value, loading, error] = useDocument(
    doc(firestore, "users", useruid),
    {
      enabled: useruid,   // make a network request if only Boolean(useruid)  is true
    }
  );

If required, I am willing to contribute

hussamkhatib avatar Aug 28 '22 17:08 hussamkhatib

#110

kaueDM avatar Sep 14 '22 12:09 kaueDM

@hussamkhatib As per #110, the approach used by this library is to support the passing of null / undefined to the hook to prevent loading

chrisbianca avatar Nov 04 '22 17:11 chrisbianca