title: How do I keep a user logged into firebase after refresh in React.JS?
body: <p>When mounting a component, I'd like to render either a log in screen or the app, depending on wether the user in logged in. However, each time I refresh, the user is logged out. How would I keep them logged in?</p>
  
  <h2>App Component:</h2>
  
  <pre><code> firebase.initializeApp(config); //init the firebase app...
  
  class App extends Component {//this component renders when the page loads
  constructor(props){
    super(props);
  
    this.state = {user: firebase.auth().currentUser};//current user
  }
  render(){
      if (this.state.user) {//if you are logged in
            return (
              &lt;Application/&gt;
            );
      } else {//if you are not logged in
            return (
              &lt;Authentication/&gt;
            );
      }
  }
  
  }
  </code></pre>
  
  <p>This is the method I'm using to log in the user (which works fine):</p>
  
  <pre><code>let email = "some";
  let password = "thing";
  const auth = firebase.auth();
  const promise = auth.signInWithEmailAndPassword(email, password);
  </code></pre>