• + 0 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;