Open MrHazimAli opened 5 years ago
The profile loading is separate from auth loading. Auth is needed in order for the listener for profile data (which lives in users/:uid
) to be attached. With that in mind, profile loading will always come after auth exists.
The onAuthStateChanged
callback is where the profile listener is attached, but it should still be attached if the user is authenticated.
It could have to do with it being react-native-firebase instead of the Firebase JS SDK, but I don't use react-native-firebase often enough to know for sure. Can you provide a full code base where this can be reproduced?
hye @prescottprue , here is the repo to reproduce the issue
https://github.com/MrHazimAli/firebaseRepro
here is credential: email: hazimhis23@gmail.com pwd: 123456
I still couldn't run your repro. But here's my speculation about the code
onAuthStateChanged
. The listener is called when login, but props.profile still doesn't have actual profile because it need to get a data from firestore and it will be updated into redux state later. And you won't see the change because onAuthStateChanged
is triggered only once when logged in, not when profile getting update.SET_PROFILE
after LOGIN
.profile
inside a component this will surely show the current state of profile.@illuminist ,
number 1 make sense.. but apparently, SET_PROFILE
is only called after I kill the app and open it back. otherwise, after LOGIN
, no redux dispatch actions are called.
I clone it back to test the repo and it's running so far using this flow:
$ git clone https://github.com/MrHazimAli/firebaseRepro.git $ cd firebaseRepro $ yarn install $ cd ios $ pod install $ react-native run-ios
@prescottprue any updates on this? I have noticed that the firestore listeners too are impacted. They do not progress from SET_LISTENER to LISTENER_RESPONSE state. The peculiar thing is that if I let 10+ seconds pass between reloads the listeners and profile loading continue to function normally.
Do you want to request a feature or report a bug?
bug
What is the current behavior?
User can use the app without login, but if the user login, they can see their profile data. after login, onAuthStateChanged is triggered, auth is updated with login user but profile still empty. this only occurring during sign in.. for sign out, user profile automatically cleared. the only way to get the profile right now is to kill the app and open it back. then profile is loaded inside redux store
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via codesandbox or similar.
What is the expected behavior?
once user login, onAuthStateChanged is triggered and get the latest profile of the user during signout and sign in
Which versions of dependencies, and which browser and OS are affected by this issue? Did this work in previous versions or setups?
tested on Google Pixel 2 Android 9 on debug mode