Skip to content

How to trigger onClick event from buttonPrev and buttonNext? #175

Closed Locked Answered by igordanchenko
JPVRS asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you for the detailed explanation. It sounds like you can provide all 3 images in the slides array

<Lightbox
  open={isLightBoxOpen}
  close={() => setIsLightBoxOpen(false)}
  slides={[
    { src: mainImageUrl },
    { src: secondImageUrl },
    { src: thirdImageUrl },
  ]}
  // the `index` prop determines the starting slide index when the lightbox opens
  index={startingSlideIndex}
/>

and then just tell the lightbox which slide to display when it opens:

setIsLightBoxOpen(true);
setStartingSlideIndex(...) // <-- specify the desired slide index here

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@igordanchenko
Comment options

Answer selected by JPVRS
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants