How to build a Stopwatch in React 🔥 | React JS Interview

Поділитися
Вставка
  • Опубліковано 5 вер 2024

КОМЕНТАРІ • 14

  • @akashingole
    @akashingole  Рік тому +5

    If you like the video, don't forget to comment. Thank you for watching ❤

  • @A1996ARP2075
    @A1996ARP2075 Рік тому

    Thanks please keep making more interview videos like these

  • @engineerthings7486
    @engineerthings7486 Рік тому

    Nicely explained 🙂

  • @SinghMusicpvtltd
    @SinghMusicpvtltd Рік тому

    Awesome Sir

  • @nitishkumarverma756
    @nitishkumarverma756 Рік тому +1

    Shouldn't we use useRef for storing now as we are not going to rerender the UI for it ?

  • @sanyamjain4777
    @sanyamjain4777 Рік тому

    Make more videos on these type of interview questions

  • @SinghMusicpvtltd
    @SinghMusicpvtltd Рік тому +1

    When u stopped the watch at 2 sec and if I want to let's continue from 2 sec then what to do sir?

    • @akashingole
      @akashingole  Рік тому

      In that case do not setTime in handlestart(), just set the default value of Time as Date.now()

  • @bhanusunka2840
    @bhanusunka2840 11 місяців тому

    const handleStart = () => {
    setTime(Date.now());
    setNow(Date.now());
    clearInterval(intervalRef.current); // Edge case: clearing the previous Intervals,
    intervalRef.current = setInterval(() => {
    setTime(Date.now());
    }, 10);
    return () => clearInterval(intervalRef.current);
    };
    Like whenever we click restart button more than one time it doesn't stop when i click on the stop
    So to overcome this clearing timeInterval before creating a new one would result in more proper implementation

  • @pratibhayadav4916
    @pratibhayadav4916 Рік тому

    When i create stopwatch but with different condition so how to should i go i stuck at that point please guide me how i build my logic

    • @akashingole
      @akashingole  Рік тому

      Hey you can text me at insta at codingjourneywithakash. Send me the ss of your code

  • @SinghMusicpvtltd
    @SinghMusicpvtltd Рік тому

    Me learning React