React 18 useDeferredValue Hook Crash Course

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ม.ค. 2025

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

  • @pouriakalantari
    @pouriakalantari 4 หลายเดือนก่อน +1

    he is the best instructor and mentor in TH-cam

  • @xor_r0
    @xor_r0 10 หลายเดือนก่อน +1

    Another great video. Now I can update version of React in my projects and upgrade the Search field in my table component. So far I used only AbortController in my service for a debounce in fetching data, but now, combining with this hook it has to be much better.
    Thank you!

  • @minhluudinh5522
    @minhluudinh5522 2 ปีที่แล้ว +11

    You are amazing. I have watched a bunch of videos and read articles about the new hooks but this is by far the best explanation.

  • @grumd0
    @grumd0 ปีที่แล้ว +13

    The problem with useDeferredValue is that the expensive loop will still have to run in the main thread at some point. And if coincidentally your user starts typing again while the thread is busy, they'll experience the same lag. Different users type with different speed and that's why useDeferredValue in my experience is not always perfect.
    In some cases using WebWorkers will be plain better. You can just make a separate thread do the job and return the results.
    You can't always just replace useDeferredValue with WebWorkers ofc, it's just nice to know about the disadvanages and alternatives.

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

    The Example on 6:34 is so clear ! Thank you !

  • @Meerasingh0704
    @Meerasingh0704 2 ปีที่แล้ว +44

    Hair tutorial on 1m subs pls :)

    • @carberi50
      @carberi50 2 ปีที่แล้ว +2

      That would be great.

    • @mridulsetia4974
      @mridulsetia4974 2 ปีที่แล้ว

      ++ lol

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

      This would be nice lol

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

      th-cam.com/users/shortsEHod_nIuz9c

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

    Awesome! Thx again Kyle :)

  • @nazardzys7514
    @nazardzys7514 10 หลายเดือนก่อน

    thanks for the awesome and straightforward explanation bro

  • @adimaralimuddin96
    @adimaralimuddin96 2 ปีที่แล้ว +4

    kyle always explains in best as possible. thanks once again!

  • @yashpatel7291
    @yashpatel7291 2 ปีที่แล้ว

    thank you so much for Free Hook Crash Course.

  • @rxrx7565
    @rxrx7565 2 ปีที่แล้ว

    The guitar is cool, you should make an intro. Nice tutorial!

  • @vibhash1994
    @vibhash1994 2 ปีที่แล้ว

    Brilliant explanation

  • @karthiksuryadevara2546
    @karthiksuryadevara2546 7 หลายเดือนก่อน

    Nice explanation, so the value we pass to useDeferredValue should always be something we get from usealState ?

  • @EvertJunior
    @EvertJunior 2 ปีที่แล้ว

    amazing! Thank you

  • @Alessandro-nq3tm
    @Alessandro-nq3tm 2 ปีที่แล้ว +6

    Which is the difference between this and useTransition? Seems the same thing to me

    • @RichardWagenknecht
      @RichardWagenknecht 2 ปีที่แล้ว +2

      useTransition wraps a block of code updating state. useDeferreredValue wraps a single value.

    • @flowerofash4439
      @flowerofash4439 2 ปีที่แล้ว

      @@RichardWagenknecht any common occurrence example of when usetransition is needed?

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

    Thank You

  • @valen8560
    @valen8560 2 ปีที่แล้ว +3

    useSyncExternalStore next plz ❤

  • @TusharBorawake
    @TusharBorawake 2 ปีที่แล้ว +23

    Hi Kyle, can we use this alternative for denouncing or throttling? It looks same as useTransition hook because it also priorities task.

    • @CrAzZyKiLleR01
      @CrAzZyKiLleR01 2 ปีที่แล้ว +11

      Kyle is not interested in responding to the community

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

    It just like debouncing, there is useDebounce create by community.

  • @RubberDuckCoding
    @RubberDuckCoding 2 ปีที่แล้ว

    VERY NICE!

  • @vladserhiychuk8925
    @vladserhiychuk8925 2 ปีที่แล้ว

    good job. Thx

  • @mukulr5171
    @mukulr5171 2 ปีที่แล้ว

    Awesome!

  • @carberi50
    @carberi50 2 ปีที่แล้ว +2

    Great explanation as always. Thanks for the video.

  • @yadneshkhode3091
    @yadneshkhode3091 2 ปีที่แล้ว

    awesome mate

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

    Hey! Can you make a video about how you create a Chrome Extension, I think it would be helpful cause it uses many different elements of code!

  • @benyamineslami573
    @benyamineslami573 2 ปีที่แล้ว

    amazing

  • @VarunJain15
    @VarunJain15 9 หลายเดือนก่อน

    can we achieve similar results with useTransition hook?

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

    How much time does this hook wait since the last input change to perform updating list? Can I change this time?

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

    I just feel stupid that I have been watching so many of your videos and just subscribed. You are a great teacher.

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

      Just subscribed a minute ago while I have been watching his videos for about 2 years. I guess because his CTA is at the beginning where audience is more interested in watching the video than subscribing.

    • @kelvinpraises
      @kelvinpraises 2 ปีที่แล้ว

      This literately just happened to me too, I've been watching since 2020 and just realized I wasn't subscribed while watching the useTransition video some minutes ago, subbed anyways.

  • @dhineshkumar8125
    @dhineshkumar8125 2 ปีที่แล้ว

    nice explanation kyle.....crystal clear!!

  • @ilkrsrc081
    @ilkrsrc081 2 ปีที่แล้ว +5

    the question is how much time does react wait? is it some arbitrary time that is implemented to React?

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

      React doesn't wait any specified time and this should not be confused with debounce at all, it just updates the value as soon as no "urgent" render is pending (caused by events like setState etc), which could be immediately after the user input (if the input causes no urgent renders), or never, if there is always an urgent render pending (some sort of animation). There is no correlation to user input / specific event frequency. A debounce is scoped to a specific event chain, and its result is urgent (just delayed until the event chain has a sufficiently long break).
      TLDR: Deferred value waits for urgent renders to stop, Debounce waits for specified events to stop (like typing a query).
      "Are we waiting for something specific to stop" => Debounce.
      "Doesn't matter, just render it at some point in time" => Deferred

  • @sharklion3
    @sharklion3 2 ปีที่แล้ว

    Great video, thank you!

  • @muratasarslan2359
    @muratasarslan2359 2 ปีที่แล้ว

    Very clear, thank you

  • @alexdin1565
    @alexdin1565 2 ปีที่แล้ว

    please can you add videos about Django channels + celery + Redis bcz you are the best can we understand everything with you

  • @zohaibkhan5270
    @zohaibkhan5270 2 ปีที่แล้ว

    Can we only use this hook in debouncing or it have some other use cases
    I think we can because useDeferred depends upon whether a value is changing or not if not then it changes the defered value so maybe we can use it in some other cases but please correct me if i am wrong

  • @MuhammadAhmedAshraf
    @MuhammadAhmedAshraf 2 ปีที่แล้ว

    how do you use google fonts i use it in css by using import i watched it from web design course i watched kevin doing it in html head which one is better ???

  • @Orenrs
    @Orenrs 2 ปีที่แล้ว

    Is this hook good for API calls as well? For example taking an input and run a search query

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

      yes, it will work well, but we can always switch to useDebounce if number of network call is a problem

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

    I watched this and useTransition and couldnt find difference between two. Plz mention the difference between UseDiffered and UseTransition. Thank you

  • @sviatoslav8776
    @sviatoslav8776 2 ปีที่แล้ว

    Very clear explanation. Thank you very much.

  • @Vptechvelly
    @Vptechvelly 2 ปีที่แล้ว

    VERY WELL EXPLAINED ..THANK YOU!

  • @memeyardthoughts1197
    @memeyardthoughts1197 2 ปีที่แล้ว +6

    Here’s another handy custom hook you can create named useActive hook to detect user activity in the browser. It’s pretty useful.
    Link- th-cam.com/video/ibcCYL6Kf14/w-d-xo.html

  • @karthikm.1804
    @karthikm.1804 2 ปีที่แล้ว

    Please bring more intermediate javascript projects

  • @RD-ld2bz
    @RD-ld2bz ปีที่แล้ว

    I watch your videos everday and i haven't recognized that video before and today i fail interview because of useDefferedValue 😢

  • @kaziupir
    @kaziupir 2 ปีที่แล้ว

    useImperativeHandle next?

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

    This hooks , i haven't known when to use it , if i type very fast , the UI is still lag

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

    I just replaced it with some use-debounce I used in a project with the same scenario - search input - but I still don't like how quick useDeferredValue changes. I ended up with more unnecessary API calls and flickers. But as always, top notch video Kyle.

    • @2ezpz2plzme
      @2ezpz2plzme 2 ปีที่แล้ว +3

      For IO-intensive tasks, I think it's best to keep it behind a debounce/throttle. `useDeferredValue` is more for CPU-intensive tasks.

  • @crazycat2969
    @crazycat2969 2 ปีที่แล้ว

    Bro, you have exactly the same guitar as me

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

    it’s basically a debounce

  • @drone_baaba
    @drone_baaba 2 ปีที่แล้ว

    You are just awesome bro 👍 please create one udemy course on React

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

    Hey, Kyle, my girlfriend says you would look more attractive if you did your hair differently. Also, she says she likes people named Kyle.

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

    React has just found out about debounce. They are moving forward.

  • @Schlumpfpirat
    @Schlumpfpirat 2 ปีที่แล้ว

    Hey Kyle, this is unrelated to the video but figured this would be the best way to reach you-
    I've seen your videos and they're absolutely fantastic. However I've been struggling with tables and keeping cells the right size. It seems like I always have table-layout: fixed; to get the desired results - but I then have to pixel nudge and it's just horrible.
    Specifically when a certain column only has ~3 characters, I cannot seem to signal that column shouldn't be ~50% of the table, but as small as possible. Or use ellipsis for a long text that would otherwise cause a line-break and therefore a multi-line cell.
    It would be great if you could to a video about that. Keep up the good work and
    Best from Germany~

    • @codesymphony
      @codesymphony 2 ปีที่แล้ว +2

      don't use tables. use flex with flex-grow 1, and basis 0, or try flex-grow 0. can also try a grid.
      use word-break: nowrap; to prevent word breaking.
      can also try using a clamped width/height using calc. ie. width: calc(1.8rem + 3vw);

  • @juguetestoys1137
    @juguetestoys1137 2 ปีที่แล้ว

    Great content as always. But can you speak more slowly, please.

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

    It is used for almost the same thing as useTransition

  • @Cryptomeyr
    @Cryptomeyr 2 ปีที่แล้ว

    Leran by doing

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

    First heart

  • @CrAzZyKiLleR01
    @CrAzZyKiLleR01 2 ปีที่แล้ว +13

    As 4 years React Dev needs to say, React getting complicater and complicater. Will probably switch to Vue or Svelte

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

      vue3!

    • @turolretar
      @turolretar 2 ปีที่แล้ว

      React is still better in every way and I have a good explanation on why that is. Unfortunately, this comment section is far too small to contain it.

    • @michalkotlicki4710
      @michalkotlicki4710 2 ปีที่แล้ว

      @@turolretar Can you give the link to the explanation?

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

      I'm good with React keeps chaning to improve its performance, but I'm sick with how JS in general keeps breeding new lib, framework, tool, test...blah blah blah, all shitt* stuffs that employers keep asking me to have when I can do the same with older lib/framework

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

      SolidJS

  • @Digitalgems9000
    @Digitalgems9000 2 ปีที่แล้ว

    or.. simply store those values in the cache and populate what the user is typing that matches. or, if it's 20,000 dynamic, simply run some behind the scenes ajax to populate the search dropdown toolip. you don't need to add a huge bloated library to accomplish this, wtf lmao

  • @feynthefallen
    @feynthefallen 2 ปีที่แล้ว

    Your "free" course isn't free if you ask me to pay by providing my data and accept marketing emails from you.

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

    People still cant use usecallback and usememo properly, now they will try to usedefferedvalue.....

  • @Cryptomeyr
    @Cryptomeyr 2 ปีที่แล้ว

    You are just awesome bro 👍 please create one udemy course on React