title: How does this Firebase onAuthStateChanged work in this code
body: <p>I have an abstract question about Firebase. Here in <a href="https://github.com/oluSammy/leadpreneur-admin/blob/master/src/App.js" rel="nofollow noreferrer">this</a> code I wonder if the listener that is set up in the <code>useEffect</code> below is called if user is signed out?</p>
  <p>I understand that when this code run the Firebase listener <code>onAuthStateChanged</code> below is attached and I wonder when user is signed out here or if user is signed out from another browser(signed in with the same credentials like Google/Facebook), will this code <code>onAuthStateChanged</code> run?</p>
  <pre><code>import React, { useEffect } from 'react';
  import './App.scss';
  import Dashboard from './pages/dashboard/dashboard.component';
  import Login from './pages/login-page/login.component';
  
  import &quot;react-loader-spinner/dist/loader/css/react-spinner-loader.css&quot;;
  import { connect } from 'react-redux';
  import { setUser } from './Redux/User/user.actions';
  import { selectUserSlice } from './Redux/User/user.selectors';
  import { auth } from './firebase/firebase.utils';
  
  const App = ({ setCurrentUser, currentUser }) =&gt; {
  
    useEffect(() =&gt; {
      const unSubscribeFromAuth = auth.onAuthStateChanged(user =&gt; {
        setCurrentUser(user);
      });
      //cleanup function
      return () =&gt; {
        unSubscribeFromAuth();
      }
    },[setCurrentUser])
  
    return(
      &lt;div className=&quot;App&quot;&gt;
        {
          currentUser ? &lt;Dashboard /&gt;   : &lt;Login /&gt;
        }
      &lt;/div&gt;
    )
  };
  
  const mapDispatchToProps = dispatch =&gt; ({
    setCurrentUser: user =&gt; dispatch(setUser(user)),
  });
  
  const mapStateToProps = state =&gt; ({
    currentUser: selectUserSlice(state)
  })
  
  
  export default connect(mapStateToProps, mapDispatchToProps)(App);
  </code></pre>