title: problem with usestate in firebase to save data
body: <p>I have a problem that I can not solve try a thousand ways and nothing</p>
  <p>I happen to show</p>
  <p>I generate a state:</p>
  <pre><code> const [totalComidas, setTotalComidas] = useState({})
  </code></pre>
  <p>After that I do a useEffect to bring me the data from firebase and I want to save it in the state but it saves it empty</p>
  <pre><code>useEffect(() =&gt; {
  
      const resultadoComidas = []
      db.collection('menu semanal')
      .get()
      .then((snap) =&gt; {
          snap.forEach((doc) =&gt; {
             const comida = doc.data()
          //    comida.id = doc.id
             resultadoComidas.push(comida)
             console.log(resultadoComidas[0])
          })
          setTotalComidas(resultadoComidas)
          console.log(totalComidas) 
      })    
  }, [])
  </code></pre>
  <p>And these are my results in console</p>
  <p><a href="https://i.stack.imgur.com/2pw9c.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>The first result in the console is before adding it to the state and the second is the new state, which seems strange to me because it brings the data correctly but when I assign it to the state it assigns it to me empty.</p>