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

84
Views
Can't get the data from firebase database to react native

I'm learning react native, and now i'm using firebase...

But i am not able to get data from firebase database as easily as java, i am wondering if i am doing something wrong somewhere, someone please help me, thanks!

It can't get the data to the setCarts...

Here is my code and firebase database!

const getCartProducts = () => {
    database()
      .ref("carts/" + user.uid + "/")
      .on("value", function (snapshot) {
        let array = [];
        snapshot.forEach(function (childSnapshot) {
          let childData = childSnapshot.val();
          let k = childSnapshot.key;
          database()
            .ref("products/" + k)
            .on("value", function (s) {
              let sData = s.val();
              array.push({
                id: k,
                count: childData.count,
                imageUrl: sData.imageUrl,
                name: sData.name,
                type: sData.type,
                price: sData.price,
                like: sData.like,
                popular: sData.popular,
                storageQuantity: sData.storageQuantity,
                description: sData.description,
              });
            });
        });
        // console.log(array);
        setCarts(array);
      });
  };

firebase database image

about 4 years ago · Juan Pablo Isaza
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!