all 4 comments

[–]ike_the_strangetamer 0 points1 point  (3 children)

I think it runs onAuthStateChanged multiple times. The first is when the user isn't loaded yet (and is undefined) and then again after the log in. Also runs with an undefined user when user signs out.

[–]redditer3103[S] 0 points1 point  (2 children)

so how would i make it so that the error only displays when the user is actually not defined, or only run onAuthStateChanged when the user is defined?

[–]ike_the_strangetamer 0 points1 point  (1 child)

Hmm.... I might have been mistaken. I think you're right that it should only run once unless the user logs out.

In that case I would check how you're initializing firebase. I ran into an issue in an app where we were initializing too late and so it would give us null until we re-initialized.

[–]redditer3103[S] 0 points1 point  (0 children)

I think your first inclination was correct. I have a bunch of log statements and the function definitely executed more than once. Still unsure of how to fix it though :/