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

206
Views
How to use SimpleImageSlider in Reactjs with an array of images from firebase firestore

I have an array of images saved in my firebase firestore documents. I want to show all images as a slide show and i found this react package that does that, react-simple-image-slider.

My images are saved this way in firestore:

enter image description here

Now I am retrieving them this way in order to add them to the slider:

const [imgUrls, setIMGUrls] = useState([]);
  const imageList = []

firebase.firestore().collection("Properties").where("propertyID", "==", propID).get().then((snapshot) => {

  snapshot.forEach((doc) => {

    const {
      imageUrls,
      features
    } = doc.data();

    imageList.push({
      imageUrls: imageUrls,
    })

    setIMGUrls(imageList)
  })
})

and using the component this way:

                     <SimpleImageSlider
                      width={896}
                      height={504}
                      images={imgUrls}
                      showBullets={true}
                      showNavs={true}
                    />

but I am getting an error that reads

"TypeError: Cannot read properties of undefined (reading 'url')
    at SimpleImageSlider"

How can I fix that?

EDIT:

console.log(JSON.stringify(images))

enter image description here

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

0

The images property should be array of objects where each object has a property url as mentioned in the usage section. Try refactoring the code as shown below:

const [imgUrls, setIMGUrls] = useState([]);


firebase.firestore().collection("Properties").where("propertyID", "==", propID).get().then((snapshot) => {
  // images from all documents in the snapshot 
  let images = []

  snapshot.forEach((doc) => {
    const { imageUrls } = doc.data();
    images = [...images, ...imageUrls.map(url => ({ url }))]
  })

  setIMGUrls(images)
})
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!