title: useEffect not respecting promise and returns null
body: <p>I'm trying to useEffect when my component first loads.  UseEffect has a call to a firebase function but it's returning null and I can't figure out why.</p>
  
  <pre><code>     const [emails, setEmails] = useState({
          reports: [],
          savedReports: [],
        })
  
          useEffect(() =&gt; {
      props.firebase.getEmailReportsTo(props.orgId)
      .once('value')
      .then(returnedEmails =&gt; {
        console.log(returnedEmails.val());
        setEmails(prevEmails =&gt; ({
          ...prevEmails,
          savedReports: [returnedEmails.val()]
        }))
      })
    }, []);
  </code></pre>
  
  <p>Here I make a call to a firebase method which returns the values.  I've confirmed there's values in that endpoint.  The above returns null.  It appears as if the console log is logging BEFORE the call finishes executing.  However I'm not sure why since console.log is in <code>then</code>.  Console.log isn't the important part but then it creates null under my state also.</p>
  
  <p>When I do this:</p>
  
  <pre><code> useEffect(() =&gt; {
      props.firebase.getEmailReportsTo(props.orgId)
      .once('value')
      .then(returnedEmails =&gt; {
        console.log(returnedEmails.val());
        setEmails(prevEmails =&gt; ({
          ...prevEmails,
          savedReports: [returnedEmails.val()]
        }))
      })
    }, [emails.savedReports]);
  </code></pre>
  
  <p>I can view the console.log with the data but this kicks into an infinite loop.
  Changing <code>[emails.savedReports]</code> to <code>[emails]</code> also returns null</p>
  
  <p>This can be broken down into two question but whatever helps me achieve the result of setting the state to the firebase call works for me.  One would be why is the useEffect not waiting for then to complete?  The other would be if [emails.savedReports is updated then shouldn't it stop executing useEffect?  However I can resolve this is cool with me.</p>