Hook for user based firestore calls #476
                  
                    
                      codercatdev
                    
                  
                
                  started this conversation in
                Ideas
              
            Replies: 0 comments
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The Issue
There is an idea out there right now that we should allow a null call to firestore, but this probably isn't the most ideal option.
This is all being discussed in several spots #463 #178 #176
@jhuleatt highlighted his reasoning within this thread about why it isn't the suggested method.
#178 (comment)
A thought about how to fix
I think it is worth talking about further because I think there is an opportunity here for a possible feature request. I like to have my profiles on users allow for overrides to their profile. So I typically will get the
Usertype date from something likeuseSigninCheckoruseUserand this will return the User for me, then when this is loaded though I also like to "extend" this to override the default Photo or other attributes like below.Typically I will wait for the
getUsercall to resolve in the Observable and then I have aswitchMapto a firestore call which then fetches the remainder of this profile data. As explained in the other examples though you cannot useuseFirestoreDocDataas a hook call without already knowing theuidfrom the user.Jeff has already pointed out that it would be best to wrap your auth call with another component and then when this becomes visible to react make your call to
useFirestoreDocDatato get the data.Example
Here is how a normal profile would work ( I will try and do a stackblitz soon).
Now in order to make a firestore call after Auth has happened I will need to wrap the profile portion, by removing
and replacing that with a new component
<AvatarProfile setProfile={setProfile} profile={profile} />This new component looks like this
Proposal
I am proposing that we make a function in
reactfirethat allows us to call anything from firestore after our authentication finishes. That way I don't have to wrap all of my components with additional functional components after auth.I could instead do
useFirestoreDocDataWithAuth(auth, ref); Then I know if data comes back I can merge if successful without the need to wrap the component.Let me know what you think??
Beta Was this translation helpful? Give feedback.
All reactions