Search in React using debouncing | useCallback

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

КОМЕНТАРІ • 33

  • @akashingole
    @akashingole  3 роки тому +8

    Thank you for watching.
    -AI😊

  • @tomasburian6550
    @tomasburian6550 2 роки тому +3

    You are the code GOD!
    Finally found exactly what I was looking for :)

  • @jitujahagirdar613
    @jitujahagirdar613 3 роки тому +2

    You made my day to easy understanding search with debounce in react. after searching lots of the video i got finally your video that me clear understanding..!
    Thanks for this video it really help me a lot..!

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

    This is Freaking Great!

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

      I do have a question though, I am having an issue regarding event pooling. Somehow the event is not passing through to the handleChange function. What do "...args" make reference to?

  • @electrodragon1211
    @electrodragon1211 2 роки тому

    Big Thanks to you BRO !!
    It worked..

  • @gunjangirdhar6701
    @gunjangirdhar6701 2 роки тому

    Big Thanks!
    It worked..😊

  • @prakarshshrivastava6422
    @prakarshshrivastava6422 Рік тому +2

    8:43 setTimeOut is not provided by javascript it is a browser api

  • @nikhilkumarjamwal5322
    @nikhilkumarjamwal5322 Місяць тому

    when i try to run the code calling api from handleChange function i am getting CORS policy.

  • @amityadav85
    @amityadav85 2 роки тому

    good work dude!

  • @devadharsank
    @devadharsank 4 місяці тому

    what the difference between passing prop as type={'text'} or type='text'

  • @anirbandas12
    @anirbandas12 2 роки тому +2

    Why use useCallback() to memoise when the function is not being passed as props to any child component?

    • @mdmustaqahmed5391
      @mdmustaqahmed5391 2 роки тому

      Yes no need of useCallback() function here, Code will work fine without useCallback() hook

  • @RavindraSingh-zg9eq
    @RavindraSingh-zg9eq 9 місяців тому

    function debounce(func, timer) {
    clearTimeout(timer);
    timer = setTimeout(() => {
    func();
    }, 4000);
    }
    onChange={(e) => {
    setInp(e.target.value);
    debounce(() => {
    console.log(e.target.value);
    });
    }} can't we use this ? i dont understand why returning another function by debounce ?

  • @priyanshchoudhary3930
    @priyanshchoudhary3930 3 роки тому +2

    Isn't this throttling cause you limit your function call to once in every 500ms. ?

  • @aashiqahmed5273
    @aashiqahmed5273 3 роки тому +2

    How to make the api result as selectable options and get the value of the text?

    • @robeeeeen
      @robeeeeen 2 роки тому

      Any idea? Looking for it still :((

  • @adivmt
    @adivmt 3 роки тому +2

    Hello Akash , can you explain why we used apply () on fn ?

  • @ankitmehrotra8519
    @ankitmehrotra8519 3 роки тому +1

    Bro It's throttling effect. Very Nicely explained though, I tried using controlled components to achieve same but cud not. Using ref we can achieve this effect

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

      No buddy. This is trailing debouncing. There is also leading debouncing.

  • @tarunkmr145
    @tarunkmr145 4 місяці тому

    Why can’t we call settimeout function and write handle change function in it ?

  • @aashiqahmed5273
    @aashiqahmed5273 3 роки тому +1

    Can i use this with redux action file?

    • @shivgaurav8567
      @shivgaurav8567 3 роки тому

      Yes , you just need to dispatch your action where he calling api

  • @ТариэлТаиров
    @ТариэлТаиров 2 роки тому

    thank you bro

  • @robeeeeen
    @robeeeeen 2 роки тому

    How to add cache handler? ❣❣❣

  • @bhagabatsahoo3112
    @bhagabatsahoo3112 3 роки тому +1

    good. Can you provide the code please ? Thanks

  • @chethanprabhu4475
    @chethanprabhu4475 2 роки тому

    useCallback hook is not required as it is not controlled input element

  • @RavindraSingh-zg9eq
    @RavindraSingh-zg9eq 9 місяців тому

    @akashingole i hope this code will work fine if there is any issue with this debouncing implementation pls let me know
    export default function App() {
    const [inp, setInp] = useState("");
    let timer;
    function debounce(func, timer) {
    clearTimeout(timer);
    timer = setTimeout(() => {
    func();
    }, 4000);
    }
    return (

    {
    setInp(e.target.value);
    debounce(() => {
    console.log(e.target.value);
    });
    }}
    name="name"
    value={inp}
    placeholder="serach..."
    />

    );
    }

  • @aigaming019
    @aigaming019 2 роки тому

    Very nicely explained 👍