You are viewing a single comment's thread. Return to all comments →
My Solution:
import React, { useState, } from "react";
function Slides({ slides }) {
const [currentIndex, setCurrentIndex] = useState(0);
const goToNext = () => { if (currentIndex < slides.length - 1) { setCurrentIndex(currentIndex + 1); } };
const goToPrev = () => { if (currentIndex > 0) { setCurrentIndex(currentIndex - 1); } };
const restart = () => { setCurrentIndex(0); };
return ( Restart Prev Next {slides[currentIndex].title} {slides[currentIndex].text}
export default Slides;
Seems like cookies are disabled on this browser, please enable them to open this website
Slideshow
You are viewing a single comment's thread. Return to all comments →
My Solution:
import React, { useState, } from "react";
function Slides({ slides }) {
const [currentIndex, setCurrentIndex] = useState(0);
const goToNext = () => { if (currentIndex < slides.length - 1) { setCurrentIndex(currentIndex + 1); } };
const goToPrev = () => { if (currentIndex > 0) { setCurrentIndex(currentIndex - 1); } };
const restart = () => { setCurrentIndex(0); };
return ( Restart Prev Next {slides[currentIndex].title} {slides[currentIndex].text}
); }
export default Slides;