Responsive slideshow in Reactjs | React machine coding question - 63

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 พ.ย. 2024

ความคิดเห็น • 9

  • @JSUltra
    @JSUltra 5 หลายเดือนก่อน +1

    Great video ! And naice images

  • @MrK-nb7xr
    @MrK-nb7xr ปีที่แล้ว +1

    // adding this line of code just below will auto-mate the slide-show
    useEffect(() => {
    const timerId = setInterval(() => {
    if (active < images.length - 1) {
    setActive(active + 1);
    }else{
    setActive(0);
    }
    console.log(active)
    }, 2500)
    return () => {
    clearInterval(timerId);
    }
    },[active])

  • @sush4617
    @sush4617 ปีที่แล้ว +1

    Hello sir, very useful video . Can you please brief on approach as to make this a autoplay slideshow , and as user hovers onto the slideshow , it pauses on that instance's picture

    • @Learnersbucket
      @Learnersbucket  ปีที่แล้ว

      Yes, sure

    • @sachinsingh-jb7td
      @sachinsingh-jb7td ปีที่แล้ว +1

      Create a state like isHover and set it to true when the user cursor enters the image and false when the user's cursor leaves the image area using "onMouseOver" and "onMouseOut". Create a useEffect, increment the state by one, and pass that state to dependency so that useEffect will run repeatedly. Now add a condition in useEffect if the isHover state is false then only increment the state otherwise don't. Don't forget to add the isHover state to the dependency.

    • @sachinsingh-jb7td
      @sachinsingh-jb7td ปีที่แล้ว

      Feel free to correct me if there is some problem in my solution .

  • @rambbg7527
    @rambbg7527 ปีที่แล้ว +1

    Source Code helps for Freshers

  • @rambbg7527
    @rambbg7527 ปีที่แล้ว +1

    Sir please provide Source Code Link in Below