Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

onAuthStateChange not working properly #77

Open
itsmeek opened this issue Nov 9, 2018 · 3 comments
Open

onAuthStateChange not working properly #77

itsmeek opened this issue Nov 9, 2018 · 3 comments

Comments

@itsmeek
Copy link

itsmeek commented Nov 9, 2018

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

@Ehesp
Copy link
Member

Ehesp commented Nov 10, 2018

Can you explain what you mean by "refreshes"?

@kawin-impekable
Copy link

kawin-impekable commented Nov 10, 2018

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 });

@partriv
Copy link

partriv commented Jan 30, 2019

also having this issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants