Here is my code const [currentImageIndex, setCurrentIndex] = useState(0); const gotoPrevious = () => currentImageIndex > 0 && setCurrentIndex(currentImageIndex - 1); const gotoNext = (GalleryImages: any) => { console.log(currentImageIndex); currentImageIndex + 1 < GalleryImages.length && setCurrentIndex(currentImageIndex + 1); }; <Lightbox isOpen={true} className="bg-black/70" onClose={() => setIsLightboxView(false)} onNext={() => gotoNext(GalleryImages)} onPrev={gotoPrevious} singleClickToZoom images={GalleryImages.map((photo: any) => ({ src: photo.src, alt: photo.alt, }))} currentIndex={currentImageIndex} renderPrevButton={() => ( <IoIosArrowBack className={`text-5xl text-primary absolute left-20 cursor-pointer`} /> )} renderNextButton={() => ( <IoIosArrowForward className={`text-5xl text-primary absolute right-20 cursor-pointer`} />