title: How to set firebase onAuthStateChanged listener in React-native
body: <p>I'm trying to use firebase database for my project(Expo for react-native) </p>
  
  <p>What I understand is that firebase.auth().onAuthStateChanged listens for the signed in/out status of the user. So when user logs off, it should be triggered again. </p>
  
  <p>I'm not sure exactly where to locate the onAuthStateChanged method in react-native. At the moment I've located it in componentDidMount, like this: </p>
  
  <pre><code>componentDidMount() {
  firebase.auth().onAuthStateChanged(user =&gt; {
    if (user) {
      console.log("logged in");
    } else {
      console.log("not logged in");
    }
  });
  }
  </code></pre>
  
  <p>It works when the component loads, but the problem is onAuthStateChanged method does not trigger when I press signout button(which has firebase.auth().signOut() method during OnPress). </p>
  
  <p>I know componentDidMount only loads once when component mounts. 
  So where should I locate onAuthStateChanged method so that when I press logout, it will listen for the signout action and triggers the onAuthStateChanged method again?</p>
  
  <p>Thank you. </p>