Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

219
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!