Skip to content

loading: false, error: undefined, value: undefined when using useDocument #17

@jameshartig

Description

@jameshartig

Thanks to #10, we are now able to do:

  const { initialising, user } = useAuthState(auth);
  const { loading, error, value } = useDocumentOnce(
    user ? db.doc(`users/${user.email}`) : null
  );

The problem is that if the user exists then a document reference is sent but useDocumentOnce returns { loading: false, error: undefined, value: undefined }. I was under the assumption that once loading is false, the value should be the DocumentSnapshot. It looks like this was caused by 01e8616 because calling setValue(undefined) ends up setting the loading value to false.

I'm not sure if the best fix is to change the useLoadingValue's reducer to check the value before setting loading to false or if instead it shouldn't call setValue(undefined) if the value is already undefined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions