title: onAuthStateChanged() inside useEffect()
body: <p>I have the problem which is mentioned <a href="https://stackoverflow.com/questions/70913564/onauthstatechanged-runs-on-every-re-render">here</a>.
  I searched, but could not find the answer. If you put a <code>console.log()</code> inside the <code>useEffect()</code> but outside the <code>onAuthStateChanged()</code> method, it just runs once which is on component mount and it is what is expected. But if you put the <code>console.log()</code> inside the <code>onAuthStateChanged()</code> (as in the example by @Abhishek Sharma) it runs whenever the &quot;auth&quot; is updated.</p>
  <p>So how is it possible that <code>useEffect()</code> is not ran on component <strong>updates</strong> but <code>onAuthStateChanged()</code> is ran on component <strong>updates</strong>? If the reason is that <code>onAuthStateChanged()</code> is an &quot;observer&quot;, could you please explain how observers work? Because I expect that <code>useEffect()</code> and all its content to run just <strong>once</strong> which is on component mount.</p>