FirebaseExtended / reactfire

Hooks, Context Providers, and Components that make it easy to interact with Firebase.
https://firebaseopensource.com/projects/firebaseextended/reactfire/
MIT License
3.54k stars 405 forks source link

Infinite request loop in useFirestoreCollection #374

Open maxprilutskiy opened 3 years ago

maxprilutskiy commented 3 years ago

Hello,

the following code results in an infinite loop when user isn't authenticated aka user.data is undefined. Is this expected?

  const user = useUser(undefined, { suspense: true });
  const subscriptions = useFirestoreCollection(
    firestore
      .collection('customers')
      .doc(user.data?.uid)
      .collection('subscriptions')

When something random and non-existent is passed to doc(myId), it throws Missing or insufficient permissions, when null is passed it throws Function CollectionReference.doc() cannot be called with an empty path, however when undefined is passed the code goes into an infinite loop and triggers hundreds of requests per second.

hcyildirim commented 3 years ago

Hi, did you solve your problem? If yes, could you help me?

steurt commented 3 years ago

@prilutskiy I've had indefinite loop/suspending issues as well with v3.0.0-rc.*. They manifested at different times at different places in my app. I managed to get it working, not sure what the root cause is though. Maybe give my workaround a try and see if it solves your issues as well. For more details, see: https://github.com/FirebaseExtended/reactfire/issues/405#issuecomment-884860980.