Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The package does not work with a single image #27

Closed
javier-mora opened this issue Jan 20, 2021 · 1 comment · Fixed by #31
Closed

The package does not work with a single image #27

javier-mora opened this issue Jan 20, 2021 · 1 comment · Fixed by #31

Comments

@javier-mora
Copy link

The package does not work when there is only one element in the array.

I know the package is designed for more than one image, but when retrieving images from an API via filters, many times you don't have control of how many images will be returned.

Here is the code for this:

<SimpleImageSlider
                    width={"500px"}
                    height={"500px"}
                    images={[
                        {url: "/images/img1.png"},
                    ]}
                    showNavs={true}
                    showBullets={false}                    
                />

Error:

TypeError: Cannot read property 'url' of undefined
SimpleImageSlider
/node_modules/react-simple-image-slider/dist/index.js:237
  234 |     currentSliderStyle = _React$useState8[0],
  235 |     setCurrentSlideStyle = _React$useState8[1];
  236 | 
> 237 | var _React$useState9 = React.useState(styles.getImageSlide(images[1].url, slideDuration, 1, useGPURender)),
      | ^  238 |     _React$useState10 = _slicedToArray(_React$useState9, 2),
  239 |     nextSliderStyle = _React$useState10[0],
  240 |     setNextSliderStyle = _React$useState10[1];
@kimcoder
Copy link
Owner

Thanks. I will check this out :)

@kimcoder kimcoder linked a pull request Feb 12, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants