onAuthStateChanged triggered twice upon Facebook login after update from 3.2.2 to latest
Issue
This is a problem for me because I'm creating Firestore onSnapshot() listeners after I know the uid.
At first I was trying to store the callbacks to unsubscribe and retrieve them through getState() in the thunk directly. Couldn't work because the two onAuthStateChanged events fire in a short time delta for the Store to be synced up.
Currently solving with a dangerous variable like this:
let GLOBAL_currentUID = null;
/*
This is called by onAuthStateChanged() when I already know the uid is a seller
/*
export function startSellershipListeners (uid) {
console.log("Registering sellership listeners for", uid)
return (dispatch) => {
if (!GLOBAL_currentUID)
GLOBAL_currentUID = uid
else if (GLOBAL_currentUID == uid) {
return false
}
dispatch(registerMembershipInfoListener(uid))
dispatch(fetchSellerMeta(uid))
dispatch(fetchOwnWishes(uid))
dispatch(fetchOwnProducts(uid))
dispatch(fetchOwnNews(uid))
}
}
Project Files
- iOS:
Podfile
iOS
ios/Podfile:
- [ ] I'm not using Pods
- [x] I'm using Pods and my Podfile looks like:
(All Firebase pods to ~> 5.9.0)
Environment
react-native-fbsdkversion:^0.8.0
- Platform that you're experiencing the issue on:
- [ ] iOS
- [ ] Android
- [] iOS but have not tested behavior on Android
- [ ] Android but have not tested behavior on iOS
- [X] Both
- If known, the version of the platform are you experiencing the issue on:
iOS 12/Android 28
- Operating System:
- [X] MacOS, version:
10.13.6 - [ ] Windows, version:
N/A - [ ] Other, please specify:
N/A
- [X] MacOS, version:
- Build Tools:
Xcode 10e.g. Xcode 10, Android Studio 3.2
React Nativeversion:0.57.1
React Native Firebaselibrary version:5.1.1
Firebasemodule(s) you're using that has the issue:- [X] Authentication
- [ ] Analytics
- [ ] Cloud Firestore
- [ ] Cloud Messaging (FCM)
- [ ] Crashlytics
- [ ] Dynamic Links
- [ ] Functions Callable
- [ ] Invites
- [ ] Instance ID
- [ ] Notifications
- [ ] Performance Monitoring
- [ ] Realtime Database
- [ ] Remote Config
- [ ] Storage
- Are you using
TypeScript?- [X] No
- [ ] Yes, version:
N/A
- Are you using Expo, e.g.
ExpoKit?- [X] No
- [ ] Yes, I've not ejected
- [ ] Yes, but I have ejected to
ExpoKit - [ ] Yes, but I have ejected to vanilla React Native
- Expo version:
N/A
Hello 👋, this issue has been automatically marked as stale because it has not had activity for quite some time. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.
I'm having this issue as well. Did you find an answer?
This issue still happening. Nothing yet?
Still checking the uid with a global variable