React Custom Hooks: useDebounce - Simply Explained!

Поделиться
HTML-код
  • Опубликовано: 25 ноя 2024

Комментарии • 84

  • @cosdensolutions
    @cosdensolutions  8 месяцев назад +2

    Hey everyone! I just launched 🚀 Project React, which is a course that teaches you React by building a real-world project. It goes way beyond what you see in these videos and walks you through step-by-step on how to build a big and complex application with React! You can check it out here: cosden.solutions/project-react

  • @codingispower1816
    @codingispower1816 Год назад +23

    Dude, if you made a full react course with testing and all of the adv concepts, i'd pay for it. Your teaching styleis clear and concise and you don't gloss over the important parts AND you did it in TS? Sheesh. Legend.

    • @cosdensolutions
      @cosdensolutions  Год назад +5

      Oh but I am making one :) stay tuned

    • @codingispower1816
      @codingispower1816 Год назад

      I can't wait!@@cosdensolutions

    • @sagardas4218
      @sagardas4218 8 месяцев назад

      @@cosdensolutions Hey bro make Next Js + Typescript course

    • @DevDone-s4y
      @DevDone-s4y 6 месяцев назад

      I hope you won't forget your youtube tagline which says "best react content on youtube" apart from paid course.

  • @MohammedShibincp
    @MohammedShibincp Год назад +1

    I see a lot of videos on RUclips, but I can’t understand anything. But in this video, I understand everything about custom hooks. thanks sir

  • @GavHTFC
    @GavHTFC Год назад +1

    Darius you lifesaver, I just knew when searching "react debounce" that you'd come up in the results, and that your solution would work! I wasn't approaching debouncing in the best way admittedly, and you've put me back on the straight and narrow, keep it up!

    • @cosdensolutions
      @cosdensolutions  Год назад +2

      damn, thank you for the kind words! really glad you find the videos useful!

  • @brandonyippp
    @brandonyippp 5 месяцев назад +1

    Seriously underrated channel, thank you so much for your continuous content!

  • @prashlovessamosa
    @prashlovessamosa Год назад +1

    You are one of the finest teacher I have found on yt the way you explain stuff amazing thanks sir
    Excited for upcoming stuff.

  • @PrashantKumar-rc5hl
    @PrashantKumar-rc5hl 4 месяца назад

    That is very nice and clean explanation every second was crucial, thanks for making the RUclips community strong by putting exactly to-the-point videos

  • @jacobwwarner
    @jacobwwarner 17 дней назад

    More examples of custom hooks please 🙌🙌

  • @amankriet
    @amankriet 6 месяцев назад

    Thanks a lot. The debounce function was not working in React and now I know why and how to do it.

  • @katrin_awsm
    @katrin_awsm 5 месяцев назад

    Thank you very much! Very useful and understandable

  • @HojjatAfsharan
    @HojjatAfsharan Год назад

    Perfect tutorial! thanks

  • @garikmelqonyan6011
    @garikmelqonyan6011 Год назад

    Good job, bro. Makes tons of sense

  • @igorbarbosa5331
    @igorbarbosa5331 Год назад

    Perfect explanation!

  • @letthesuntalk
    @letthesuntalk Год назад

    really nice, I've been learning a lot from your videos.

  • @hilkiahlavinier
    @hilkiahlavinier Год назад +1

    Nicely explained!

  • @_briantravis
    @_briantravis 10 месяцев назад

    Exactly what I was looking for :D

    • @_briantravis
      @_briantravis 10 месяцев назад

      what vscode theme are you using?

  • @ravisankarp61
    @ravisankarp61 Год назад

    Excellent and I loved ur videos and channel.

  • @kelvinnwachukwu8141
    @kelvinnwachukwu8141 10 месяцев назад

    This is awesome as your videos has helped me alot

  • @brNoMundo123
    @brNoMundo123 10 месяцев назад

    Eu amei o vídeo! ❤seu conteúdo é demais!

  • @BeyzaAtay-wx6ou
    @BeyzaAtay-wx6ou 15 дней назад

    Thank you for the video. What is the extension that helps you complete code?

  • @chrishanthacosta4093
    @chrishanthacosta4093 5 месяцев назад

    good explanation bro..

  • @shub226
    @shub226 Год назад

    Easiest implementation of Debounce Search

  • @themangabreakdown3892
    @themangabreakdown3892 Год назад

    Hey, your videos are so nicely explained, I just want to request you one thing, could you please make a explanation video about the MERN stack, and how much knowledge do we need to gain to land a job as the MERN stack developer? like in every field, react, express, mongodb, and node.

    • @cosdensolutions
      @cosdensolutions  Год назад

      the only thing is I'm more focused on React specifically for now, not dabbling too much into DB or backend stuff. Will do more of that once server components are more prominent in the industry 🤙

  • @atifasadkhan
    @atifasadkhan 8 дней назад

    thankyou very much!!

  • @prashantbharati1867
    @prashantbharati1867 4 месяца назад

    Beautiful ❤

  • @billyfigueroa1617
    @billyfigueroa1617 10 месяцев назад

    Great video. Typically in react we load all the users when we load the page so when we are doing a search we are searching through the state on the fronted
    Nowadays, this type of issue, seems to be more realistic in an older styled app but if I am wrong, please correct me

  • @KaveriJayan
    @KaveriJayan 9 месяцев назад

    So helpful ❤

  • @icoderdev
    @icoderdev Год назад +1

    The is so much helpful, thanks so much.

  • @MEET4RIDE
    @MEET4RIDE Год назад

    Many Thanks!

  • @robinemelanson
    @robinemelanson Месяц назад

    Thank You

  • @sunil_mg_photography
    @sunil_mg_photography Год назад

    Thanks you so much bro ❤ nice explaination can you please do a detailed video on react virtualization

  • @tikkyfoxyt6831
    @tikkyfoxyt6831 3 месяца назад

    Great dude 😮 thank yue

  • @codingispower1816
    @codingispower1816 Год назад

    Can you do a video on Higher order components? You teach well.

  • @AbdelrahmanSameeh
    @AbdelrahmanSameeh 9 месяцев назад

    nice work

  • @nfaical3
    @nfaical3 11 месяцев назад

    Thanks 👍

  • @matteo6056
    @matteo6056 Год назад

    Great videos, but isn't your useDebounce hooks same as Reacts useDeferred hook with possibility to set up timeout?

    • @cosdensolutions
      @cosdensolutions  Год назад

      yes, useDebounce is the same thing but works through a delay. useDeferredValue is handled automatically through React without a fixed delay

  • @Andres-Estrella
    @Andres-Estrella 5 месяцев назад

    thanks !

  • @IbanTheOne
    @IbanTheOne 4 месяца назад

    Could it be used the startTransition for this? I've been testing, and I don't think is pretty useful for this case.

  • @TausifShekh-j5x
    @TausifShekh-j5x Год назад

    Nice Man great excellant

  • @alvinacosta2312
    @alvinacosta2312 Год назад

    hello good sir, may i just ask the difference of adding 'search' as value prop for your input as compared to not using the value prop but still using setSearch in the onChange? is it the same or which one is better? thank you

  • @AbsolutePain
    @AbsolutePain Год назад

    Thanks ! The explaination was clear and crisp . Can you make a video on how to organize /file sturucture your api calls using tanquery || custom hooks . Can we have like only 4 custom hooks for crud api calls ? i just want to learn prod level things from you . Thanks for the great vid

    • @cosdensolutions
      @cosdensolutions  Год назад

      will add it to the list! But also, I'm currently working on a course that will build a big project meant for production, so there will be tons to learn there too!

  • @xgenious
    @xgenious 8 месяцев назад

    useful tips

  • @int0therain44
    @int0therain44 9 месяцев назад

    Just a question. Isn't it better, to use import { debounce } from 'lodash'; ? it gave a lot of features. What is your opinion when looking at the documentation ?
    Thank !

    • @cosdensolutions
      @cosdensolutions  9 месяцев назад +1

      You can, but it is a big library and if you don't use a lot of its functions, sometimes its easier to just write it yourself

    • @int0therain44
      @int0therain44 9 месяцев назад

      @@cosdensolutions Thank for your reply ! I finally ended up using this :
      import { useDebounce, useDebouncedCallback, useThrottledCallback } from "use-debounce";
      This is a light npm library in typescript.

  • @helenasdiaries515
    @helenasdiaries515 10 месяцев назад

    cool thanks

  • @jubyaid1235
    @jubyaid1235 6 месяцев назад

    what is the chat gpt add on being used?

  • @minhnguyendung4453
    @minhnguyendung4453 Год назад +1

    I hope you make a seri to teach async JavaScript (promise, async await,...) I don't understand how it's works

  • @imadimad8814
    @imadimad8814 11 месяцев назад

    Can we use useRef hook to do the same thing

  • @nikunjkhakhkhar1030
    @nikunjkhakhkhar1030 3 месяца назад

    the functionality of useDebounce and useDeferredValue look very same, are they really same or is there any difference?

    • @cosdensolutions
      @cosdensolutions  3 месяца назад

      useDeferredValue updates as soon as nothing else is blocking it. It's also dependent on how performant the user's device is. Faster device = faster updates. useDebounce is time based only regardless of anything else

  • @mydailythoughtss
    @mydailythoughtss 2 месяца назад

    👍

  • @icoderdev
    @icoderdev Год назад

  • @jritzeku
    @jritzeku Год назад

    Can you use useDebounce with formik ?Im currently having an issue where every keystroke in form field causes component to re-render like 2-3 times. Apparently it's a known issue with formik that is unresolved. Perhaps useDebounce can be used here.

    • @cosdensolutions
      @cosdensolutions  Год назад +1

      to do that, you would have to create your own input components that make use of useDebounce and manually update the state debounced! You could also try RHF as an alternative to Formik for better perf

  • @salok1508
    @salok1508 Месяц назад

    Why not usedefferedvalue ?

  • @katejohnson6411
    @katejohnson6411 Год назад

    Why doesn't it trigger on the first letter "render", maybe I don't correctly understand exactly.

    • @cosdensolutions
      @cosdensolutions  Год назад

      Because it defers triggering until when the ms have elapsed!

  • @helenasdiaries515
    @helenasdiaries515 10 месяцев назад

    it says I cant accept the invite to discord(((

    • @cosdensolutions
      @cosdensolutions  10 месяцев назад

      it should work, maybe try a different browser?

  • @saqibmuhammad7218
    @saqibmuhammad7218 Год назад

    LOL❤‍🔥

  • @xthesly
    @xthesly Год назад

    Hi, better use fetch abortion ?

  • @kalideb-y3y
    @kalideb-y3y 10 месяцев назад

    I wanna know why you used hooks in useDebounce? It works without them like this.....
    **********************************
    let timeId;
    function useDebounce(functionToDelay, delay == 1000) {
    clearTimeout(timeId)
    timeId = setTimeout(() => {
    functionToDelay()
    }, delay);
    }
    export default useDebounce
    // then import the useDebounce and put it inside of the useEffect
    **********************************

    • @cosdensolutions
      @cosdensolutions  10 месяцев назад +1

      well, based on "// then import the useDebounce and put it inside of the useEffect", you're also using hooks. You basically have to use hooks to implement this

    • @kalideb-y3y
      @kalideb-y3y 10 месяцев назад

      @@cosdensolutions I mean there's no hooks inside the body of my example

    • @sahilgupta9622
      @sahilgupta9622 2 месяца назад

      You're performing side effects here so you need to put this in useeffect and hence it becomes your custom hook

  • @StephenArpad
    @StephenArpad Год назад

    In my case, I've more than one input compnent.
    In one I type, let's say, the "Zip Code",
    In the one, I type in the "Street Address",
    With this I mean, that I need 2 inputs here, so my call to the API can take place..
    However, when implementing this functionality, I get instead:
    *Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency arrar, or one of the depdendecies changes on every render*
    Has anyone experienced this scenario already?
    What solution did you apply?

  • @roanacedev
    @roanacedev Год назад

    ❤❤

  • @hrutikdhumal402
    @hrutikdhumal402 Год назад

    ❤❤❤