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

260
Vistas
Why my image slider only show the first image instead of all 3 images?

I want to make an image slider in my application using the 'react-simple-image-slider ' package. But it only show the first image only..

In my firestore, my imageUrl is stored like this:

firestore

In the documentation of the package, it shows that the 'images' should be stored in this format:

The website of this package: https://www.npmjs.com/package/react-simple-image-slider

documantation

Then, in my application, I have fetched the data and store the imageUrl into the 'image' and pass it into 'SimpleImageSlider' to use it.

const ProductPage = ({ collection, match }) => {
    const { items } = collection;
    

    const image = [{url: items[match.params.itemId - 1].imageUrl}];

    console.log(image);
    
    return (
        <div className='collection-page'>
        
        <SimpleImageSlider 
            width={500}
            height={500}
            images={image}
            showBullets={true}
            showNavs={true}
        />
        
            <div className='items'>
                {items[match.params.itemId - 1].name}
            </div>
        </div>
    )
};

However, the application only show the first image in the slider:

slider

I have console.log(image) and I thought I already store the 3 imageURL into the array, but I have no idea why it only displays the first one? Is it something wrong on the method I store the 'image' and how can I convert it to fit the structure that the documentation need from the data I fetched from database?

console

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Your array is of format url: [], when the docs say each object in the array should be of format { url: "" }. So, ensure your array looks like this:

[
    { url: "https://..." },
    { url: "https://..." },
    { url: "https://..." },
]
about 4 years ago · Juan Pablo Isaza Denunciar

0

This should work as it will assign an object to each item


const ProductPage = ({ collection, match }) => {
    let { items } = collection;
    

    let image = []

    useEffect(()=>{
      items.map(item=>image.push({url: item.imageUrl}))
    },[])
    

    console.log(image);
    
    return (
        <div className='collection-page'>
        
       {image.length && <SimpleImageSlider 
            width={500}
            height={500}
            images={image}
            showBullets={true}
            showNavs={true}
        />
        }
            <div className='items'>
                {items[match.params.itemId - 1].name}
            </div>
        </div>
    )
};
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