react-native-firebase-starter
react-native-firebase-starter copied to clipboard
onAuthStateChange not working properly
I freshly cloned this repo (Friday, Nov. 9, 2018) and added the following code to componentDidMount
in the App.js
file
async componentDidMount() {
// TODO: You: Do firebase things
// const { user } = await firebase.auth().signInAnonymously();
// console.warn('User -> ', user.toJSON());
// await firebase.analytics().logEvent('foo', { bar: '123'});
---> firebase.auth().onAuthStateChanged((user) => {
console.log({ user });
});
}
There is a vital issue where the callback for onAuthStateChanged
gets called every other time. On the first refresh, the callback gets invoked which logs the user. On the following refresh, the callback does not get invoked and the log does not get call. This cycles repeats for all subsequent refreshes
Can you explain what you mean by "refreshes"?
He used Command + R to refresh iOS simulator. On first refresh, onAuthStateChanged is triggered and there is a log from console.log({ user });
but if he refresh it again, this time onAuthStateChanged is not triggered and we can't see any log from console.log({ user });
also having this issue