The useTransition hook

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

КОМЕНТАРІ • 18

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

    Never knew until now use of useTransition hook. You are superb

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

    Thanks for this, Ryan! 🙏

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

    Loved the course! Looking forward to more 👍

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

    Really good.

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

    Can you please share the github repo?

  • @havokgames8297
    @havokgames8297 8 місяців тому

    It's a good demonstration on how to use it, but I think I missed how it works. Is "router.push" a suspense compatible function? It isn't obvious how react knows when the transition is complete.

    • @RyanToronto
      @RyanToronto  8 місяців тому +1

      Great question!
      Yup, router.push is suspense compatible. It sets states that would cause the application to suspend. That's how React is aware of the transition... the fact that you're setting state causes a Suspense boundary to render.
      Then React knows that the transition is complete when the new URL (state) has loaded all it's data and doesn't render any more Suspense boundaries.

  • @MrJettann
    @MrJettann 8 місяців тому

    Doesn't it render a page on the server for every key change? Or it have something like debounce under the hood? Should we wrap it to denounce ourselves?)

    • @RyanToronto
      @RyanToronto  8 місяців тому

      Yup! You can wrap it in debounce if you'd like to avoid going to the network right away.

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

    Can it work with aaync functions

    • @RyanToronto
      @RyanToronto  4 місяці тому +1

      In the upcoming React 19 release there will be support for transitions to take an async function. Right now they are calling these "async transitions". Hope that answers your question!

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

      @@RyanToronto I have been using them with server actions from next especially the isPending, I don't know if it is really a good idea since most server actions are asynchronous

    • @RyanToronto
      @RyanToronto  4 місяці тому +1

      @@emmanuelxs6143 Oh yah with Next.js you can absolutely use async transitions

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

      @@RyanToronto thanks for the update, I appreciate