React v18 Hooks - useTransition vs useDeferredValue Examples & Comparison

Поділитися
Вставка
  • Опубліковано 2 січ 2025

КОМЕНТАРІ • 51

  • @DaveGrayTeachesCode
    @DaveGrayTeachesCode  2 роки тому +5

    React 18 includes the new hooks useTransition and useDeferredValue. Both of these hooks are based on concurrency. They can be useful, but they shouldn't be used all of the time. We'll look at both how to use and when to use these new hooks. If you are new to React, I recommend starting with my React JS for Beginners full course here: ua-cam.com/video/RVFAyFWO4go/v-deo.html

  • @AB_AB
    @AB_AB 2 місяці тому +1

    A little progress every day surely does go a long way. Thank you.

  • @Jorgeee
    @Jorgeee 2 роки тому +5

    Been lurking on your channel for a couple of hours. I'm very impressed by the amount of content and quality produced. Looking forward to the Discord server!

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

    Best channel i ever seen on UA-cam. Dave makes so simple to understand.
    Keep it up dude

  • @abdulazeez.98
    @abdulazeez.98 Рік тому

    Awesome. The best video I saw regarding this topic

  • @karthik_pushparaju
    @karthik_pushparaju 29 днів тому

    Shouldn't we use previous value while setting state at 2:33

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

    You're awesome, Dave! Thanks!

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

    Thank you, Dave) Very clearly explained

  • @kishoreandra
    @kishoreandra 2 роки тому +1

    Thanks for the video Dave ...
    Would love to see a series wherein -
    How to do things in React +
    - general scenarios / use cases
    - filter / sort
    - pagination
    - infinite scrolling
    - search functionality ( debounce technique)
    - lazy loading stuff
    - file upload
    - validations using form
    Many more ....
    I have gone through the login authentication series ... My goodness 😍 huge respect Dave 🙏💯
    -

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому +1

      Great suggestion! I like this list and I will work to fit these topics in! 💯🙏

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

      @@DaveGrayTeachesCode Amazing Dave, Thank you 😍 ... Intention is most of the jobs have similar functionalities to implement more or less, you know better than me 😄 ...

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

    The useTransition hook strikes me as a way to manipulate the DOM after it's fully rendered. Thanks for these video's Dave, I've been watching your content for several months now.

  • @ahmad-murery
    @ahmad-murery 2 роки тому

    Nice video,
    Thanks Dave, you always come to the rescue.
    Now I think I need to re-evaluate my react-abilities 🤔😎

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому +1

      Thank you, Ahmad. 🙏 I have no doubt that your programming abilities are excellent my friend 💯

    • @ahmad-murery
      @ahmad-murery 2 роки тому

      @@DaveGrayTeachesCode Sometimes my 2.5 brain cells stop and need a kick to start again, especially when so many things pull you back and lower your motivations.
      Thanks to you my friend👍

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

    Greate content and very clearly. I hope in the near future there will be a video on how to make a real project. Thank you so much!

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому +1

      Thank you! 🙏 Yes, MERN project coming soon - after a short vacation 🌴

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

      @@DaveGrayTeachesCode Nice :D Waiting for this 🤩☺️

  • @dharmeshgohil9375
    @dharmeshgohil9375 2 роки тому +1

    One word awesome

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

    So good tutorial

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

    Wonderful!

  • @安全保密
    @安全保密 Рік тому

    I feel that the difference between them is similar to useMemo and useCallback, only the application scenario is different, and they can be used together technically but not reasonable.

  • @KochharAmandeep
    @KochharAmandeep 2 роки тому +1

    Hi Dave, can i get the name of your vs code theme?

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

    Do we really need the "startTransition" function inside "useEffect" in practical example? useEffect already depends on "deferredInput", which itself tells the react to execute its callback with lower priority. A bit confused between these two hooks, looks like they duplicate each other. Devs, please explain.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому +1

      Just one example. I suggest playing around with it and experimenting to best learn how it works. It's new. More examples will surely come too.

    • @安全保密
      @安全保密 Рік тому +1

      useMemo is a good way to achieve the same goal

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

    I wonder if these can be somehow used to debounce API calls / to implement a simpler version of a useDebouce hook

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

      Absolutely. That is essentially what I am doing in Example 2 in this video except I use it to debounce a search filter instead of an API request.

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

      @@DaveGrayTeachesCode but if that was an actual API request, wouldn’t it still hit the endpoint N times if the user input N characters ?

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

      @@michaelvigato3228 yes, it would. An actual debounce gives you more control, but this is similar in some ways.

  • @me-wtf
    @me-wtf 2 роки тому

    I can't able to install create react app with yarn which step of command i have to follow

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

      Keval, follow the instructions shown here: reactjs.org/docs/create-a-new-react-app.html

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

    So how to fix the backspace search problem?

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

      The fewer characters, the more records this example has to filter through. This is true both typing forwards and when removing characters.

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

      @@DaveGrayTeachesCode I mean like when u r typing forward quickly. Its only show the final text such as "222", but when u r removing character its show every text from
      " 22"
      "2"
      "" -> the final text
      How to make the console log only show the final text for backward typing?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому +1

      @@eugenepranoto3824 it is due to not having as many records to filter when you have typed more characters. Therefore, going backwards, it gets the results faster to slower. When you start with no characters typed, it is slower to faster so you are able to type more before the app responds.

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

    What's the name of your VSCode theme?

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

    Can i Ask u for help on a react game? U have discord so i Can explain the question detailed?

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

      I am launching a Discord near the end of this month (June 2022). I hope to build a community that is helpful. I do not have the extra time to help with viewer's projects on my own.