The new `useTransition` hook with 3 example usecases

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

КОМЕНТАРІ • 43

  • @dreamsachiever212
    @dreamsachiever212 11 місяців тому +20

    this channel is so underrated. Thanks for the education. I have learned and still learn from you

  • @zaqqeus
    @zaqqeus 11 місяців тому +2

    دم شما گرم 😊

  • @temitopedavid9508
    @temitopedavid9508 11 місяців тому +2

    As expected! Another new thing to learn

  • @afshinkaramifar4429
    @afshinkaramifar4429 11 місяців тому +3

    like always, great tutorial, well done 👏

  • @kennyNn
    @kennyNn 11 місяців тому +1

    Can this be used on a server component without converting to a client component

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

      You can use the `startTransition` function on the server, but state updates only happens on the client.

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

      @@hamedbahram that's fine as long as the page remains server rendered

  • @godlyradmehr2004
    @godlyradmehr2004 11 місяців тому +1

    Really useful ❤❤❤❤❤

  • @baychaoz
    @baychaoz 5 місяців тому +1

    You are by far one of the best of the few people who manage to explain clearly and straight to the point. That's overly undervalued nowadays. Looking forward to the next stuff I'll grasp from your next Nextjs vid pal.

    • @hamedbahram
      @hamedbahram  5 місяців тому

      Thank you! I'm glad to hear that, and welcome onboard!

  • @BroccoliDev
    @BroccoliDev 5 місяців тому +1

    What an amazing tutorial! Clearly made me understand this problem!

    • @hamedbahram
      @hamedbahram  5 місяців тому +1

      Thank you! Glad it helped!

  • @konradhylton
    @konradhylton 11 місяців тому +2

    Useful

  • @jakeycakester
    @jakeycakester 11 місяців тому +1

    Can this be used with other state management libraries like zustand?

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

      That's a good question! I don't know... I'd have to try.

  • @shahryartavakkoli
    @shahryartavakkoli 11 місяців тому +1

    Thank you

  • @rezakhani8627
    @rezakhani8627 10 місяців тому +1

    Hello, I want to use SSR (Server-Side Rendering) and also use useState. Is it possible to do such a thing?
    In fact, I want to include the comments section where I display 20 comments using SSR and display the rest using the client-side rendering. I want to use them in a combined way, but I don't know how to do it. I know how to fetch more comments, but I don't know how to render that part from the beginning. Can you please provide an explanation? Thank you.

    • @hamedbahram
      @hamedbahram  10 місяців тому

      Sure, you can do that. Watch the video I have on Infinite scrolling where I fetch some initial data and use server actions to load more.

  • @borislavppetrov
    @borislavppetrov 17 днів тому

    Hey Hamed - appreciate the tutorial! One question, to make your advice more applicable to a real-world scenario:
    In the tabs example, I noticed you only put an “isPending” prop on the Team tab, because it suited the demo (where you were only switching from Team to Contact and back). But in a real-world scenario, you’d want an implementation that is uniform across all the tabs. How would you accomplish that? Would you have three separate useTransition calls and therefore, three separate [isPending, startTransition] pairs (e.g. [isPendingAboutTabTransition, startAboutTabTransition], [isPendingTeamTabTransition, startTramTabTransition], [isPendingContactTabTransition, startContactTabTransition])?

    • @hamedbahram
      @hamedbahram  16 днів тому

      No you don't need three useTransition calls, you can use the isPending plus the activeTab state for every tab to showing loading UI.

    • @borislavppetrov
      @borislavppetrov 16 днів тому

      @ but isn’t the whole point that the transition starts before the setActiveTab has taken effect? In which case isPending would be set to true as soon as a new tab is clicked, while activeTab would still hold the previously selected tab name

    • @hamedbahram
      @hamedbahram  16 днів тому

      @@borislavppetrov No that's not the point. Marking the state as a transition means it's a lower priority, it doesn't block the UI and can be interrupted. Once a button is clicked the activeTab state is updated and the render process of the active tab starts, and since it's marked as a transition it can be interrupted in case of slow/expensive renders. Did you try what I suggested?

    • @borislavppetrov
      @borislavppetrov 16 днів тому

      @@hamedbahram apologies, I have not yet tried your suggestion. I will do so before commenting further 🙏

  • @praiseoshilim1006
    @praiseoshilim1006 11 місяців тому +1

    Great Video! Please could you make a tutorial on next-redux-wrapper.

    • @hamedbahram
      @hamedbahram  11 місяців тому +1

      Please don't use Redux.

  • @sahajranipa
    @sahajranipa 5 місяців тому +1

    Hey can you share your notion nextjs notes with us it would help us in making notes about nextjs

    • @hamedbahram
      @hamedbahram  5 місяців тому

      These are the module content from my NextJs course.

  • @hbela1000
    @hbela1000 11 місяців тому +1

    cool, thx.

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

    According to your last localization video, i have implemented the language switch system.
    but the issue I am getting is from the middleware you created. i am not getting my static files from the public folder.
    export const config = {
    // Matcher ignoring `/_next/` and `/api/`
    matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"],
    };
    suppose I remove this matcher string and put simple "/" the static files load properly. can you tell me the solution? what do I need to change? please. thanks

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

      Can you leave the comment on the related video?

  • @fakhrulislamfuad8072
    @fakhrulislamfuad8072 11 місяців тому +1

    nice video bro.. Can you do something with web-component with nextjs? still now, there is no video related to this topic in the youtube and even the google doesn't have any recent posts regarding this.

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

      I'll have that in mind. Thanks for the suggestion.

  • @uixmat
    @uixmat 11 місяців тому +1

    Love this one Hamed 🫶🏻