Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda