Feature request. New hook to monitor updates for the current user.
The useAuthState hook only updates if the user logs in or logs out and not if the user updates in any way. This is a limitation of the underlying onAuthStateChange method described here: https://firebase.google.com/docs/reference/js/firebase.auth.Auth#onauthstatechanged
Proposal
New useCurrentUser hook which listens to updates to the user as well as login / logout events
Thoughts This is likely to need a few things:
- A context provider that sits at the top level of the application and stores the current user
- A series of hooks that wrap each of the
updatemethods available in Firebase Auth and updates the user within the context
See https://github.com/CSFrequency/react-firebase-hooks/issues/108 for further background.
Has there been any updates on this? its exactly what I need for an app I'm working on.
Is there a reason you couldn't use onIdTokenChanged - It seems like this updates any time a user logins/logs out AND whenever the id token refreshes.
Is there a reason you wouldn't want to use that as the higher-level state? Could we make this an optional config in the the useAuthState object or create a new hook useLegacyAuthState