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

190
Views
Get documents from Firebase but if they are already showing - dont show again

I have the following code:

const getFromFirebase = () => {
    //1.
    let storageRef = storage.ref(`${user1}/${currentItem.id}`);
    //2.
    storageRef.listAll().then(function (res) {
        //3.
        res.items.forEach((imageRef) => {
          imageRef.getDownloadURL().then((url) => {
              //4.
              if (allImages.indexOf(url) === -1) {
              setImages((allImages) => [...allImages, ({Test : url, Test2 : imageRef.name})]);
              }
          });
        });
        
      })
      .catch(function (error) {
        console.log(error);
      });
  };

I am calling this function on a tab onclick - it works in that it shows the documents but if I click the tab again it simply repeats itself - how do I run a check that if all documents are showing already to not double up?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

work with callback function, you did not enter an empty array.

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!