Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

209
Visualizações
Using ReactJs with Cloud Firestore V9, I have an issue with rendering to the dom

I'm learning how to use Cloud Firestore from Firebase combined with React JS. For starters here what my Cloud Firestore data looks like... enter image description here I was reading the documentation for V9 but I still had issues. Link to -> Firebase docs : Listen to multiple documents in a collection

I actually even copied and pasted what I read and it worked! BUT!! Only for a brief moment. I wasn't sure if I changed the code by accident. Since for some reason it wasn't rendering to the dom, I console.log a few items and it showed something was happening. I was able to see data values in the console! But still nothing was being rendered. Here's my code... and screenshots of my console.

  const firebaseApp = initializeApp({
apiKey: "Hidden",
authDomain: "Hidden",
projectId: "Hidden",


 });
  const db = getFirestore();

  const [dataFB, set_dataFB] = useState([]);

  async function getSomethingTEST() {
    let items = [];
    const q = await query(collection(db, "WNA-Pasteur-Items"));
    await onSnapshot(q, (querySnapshot) => {
      querySnapshot.forEach((doc) => {
        items.push(doc); // <-- Here I also tried doc.data().nameENG
      });             // And was able to see the specific values in the console. 
      console.log("What is inside: ", items.join(", "));
    });
    set_dataFB(items);
  }

  useEffect(() => {
    getSomethingTEST();
  }, []);

The first console.log with only items from doc , I got this... enter image description here The second console.log with doc.data().nameENG , I got this... enter image description here

Then with my JSX code looked liked this.

    <p>please work</p>
    {dataFB.map((e) => (
      <div key={e.id}>
        <h3>{e.nameENG}</h3>
      </div>
    ))}

Which rendered this... enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Push the document data instead of document snapshot:

items.push(doc.data())

Then stringing before rendering:

console.log("What is inside: ", JSON.stringify(items.join(", ")))
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda