JavaScript Why does my firebase onAuthStateChanged() trigger multiple times? (React Native)

My firebase method onAuthStateChanged() trigger several times when I sign in and out using firebase-authentication according to console.log. Isn't it supposed to trigger only once at login and once at logout. The result is that when signing out, the navigation to a previous page is triggered several times. Here's the code:

componentDidMount() {
    fbAuth.onAuthStateChanged(user => this.loginFunc(user));
}

loginFunc(user) {
   if (user) {
     console.log('LOGGED IN');
}else {
  console.log('LOGGED OUT');
  this.props.navigation.navigate('FbLogin');
}
console.log('onAUTH LOGGED IN: ', user);
}

This is what the console looks like. As you can see both login and logout are triggered on just a single logout click. On login, it triggers twice....

LOGGED OUT
FbLogin.js:46 onAUTH:  null
LoggedIn.js:27 LOGGED OUT
LoggedIn.js:30 onAUTH LOGGED IN:  null
FbLogin.js:44 LOGGED OUT
FbLogin.js:46 onAUTH:  null

My logout button looks like this:

<TouchableHighlight //LOGOUT
   style={{
      ...
   }}
   onPress={() => {
      fbAuth.signOut();
      this.setState({ loginState: "You are logged out" });
   }}
   >
      <Text>Logout</Text>
   </TouchableHighlight>
Answer:1

var garbage = document.getElementById("garbage"); garbage.addEventListener("click",function(){ garbage.style.color = "#66c144"; } <link href="https://use.fontawesome.com/releases/v5.0.10/...

var garbage = document.getElementById("garbage"); garbage.addEventListener("click",function(){ garbage.style.color = "#66c144"; } <link href="https://use.fontawesome.com/releases/v5.0.10/...

  1. change color font awesome
  2. change color font html
  3. change color font awesome icon
  4. change color font in outlook
  5. change color font latex
  6. change color font wordpress
  7. change color font css
  8. change color font photoshop
  9. change color font on iphone
  10. change color font instagram
  11. change color font in facebook
  12. change color font online
  13. change color font visual studio
  14. change color font indesign
  15. change color font in word
  16. change color font awesome icon on hover
  17. change color font whatsapp
  18. change color font ml
  19. change color font instagram story
  20. change color font excel formula

I have a main.js with React.render( <h1>Hello, world!</h1>, document.getElementById('myDiv') ); I am using CodeKit, and it spits out the error: Unexpected token: ...

I have a main.js with React.render( <h1>Hello, world!</h1>, document.getElementById('myDiv') ); I am using CodeKit, and it spits out the error: Unexpected token: ...

  1. react unexpected token expected
  2. react unexpected token ' '
  3. react unexpected token in json at position 0
  4. react unexpected token import
  5. react unexpected token export
  6. react unexpected token return
  7. react unexpected token if
  8. react unexpected token fragment
  9. react unexpected token svg
  10. react unexpected token arrow function
  11. react unexpected token function
  12. react unexpected token const
  13. react unexpected token state u003d

So, I'm picking up JavaScript since I just seems to enjoy it. I bought an online course, and now facing a challenge in my code. It's a pretty simple one, so hopefully one of the experts out there can ...

So, I'm picking up JavaScript since I just seems to enjoy it. I bought an online course, and now facing a challenge in my code. It's a pretty simple one, so hopefully one of the experts out there can ...

  1. javascript sort different results
  2. javascript regex different results

Hi I want to use a similar functionality like : Using Inline Templates in Angular But in my case url will be dynamic. for example in below code url will have /first or /second but in my case it will ...

Hi I want to use a similar functionality like : Using Inline Templates in Angular But in my case url will be dynamic. for example in below code url will have /first or /second but in my case it will ...

  1. inline template angular 8
  2. inline template angular
  3. inline template angular 6
  4. inline template angular 4
  5. inline template angular 2
  6. inline template angular 7
  7. inline template angular component
  8. inline template angular 2 example
  9. inline style angular template
  10. angular inline template example
  11. angular inline template vscode
  12. angular inline template variable
  13. inline javascript in angular template
  14. angular inline template directive
  15. angular inline template command