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

261
Views
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 answers
Answer question

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 Report

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 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!