banthagroup / fslightbox-react

Basic version of Fullscreen Lightbox for React.js. Website: https://fslightbox.com/react
MIT License
169 stars 23 forks source link

Question: How to start the lightbox already opened? #139

Open rejas opened 4 years ago

rejas commented 4 years ago

Thanks a lot for your library, but I am wondering how I can add it to a page and use a parameter to open it with a specific index when the page is loaded? Couldnt find anything in the docs or stackoverflow. You got any idea or is that not possible?

saeta-eth commented 4 years ago

Hi @rejas. As far as I know, you can use openOnMount property to start with the lightbox already opened.

rejas commented 4 years ago

Thanks for the info, but I tried that and all I got then was

Uncaught TypeError: Cannot read property 'zero' of undefined

My code looks like this:

      <FsLightbox
        toggler={toggler}
        sources={lightboxImages}
        sourceIndex={imageIndex}
        openOnMount={true}
      />

Seems like something related to issue #157 ?

piotrzdziarski commented 3 years ago

Maybe you were passing empty sources at start? The #157 was solved, maybe your issue too.