The useTransition hook

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

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

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

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

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

    Thanks for this, Ryan! 🙏

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

    Loved the course! Looking forward to more 👍

  • @MrJettann
    @MrJettann 7 месяцев назад

    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  7 месяцев назад

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

  • @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  7 месяцев назад +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.

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

    Really good.

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

    Can you please share the github repo?

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

    Can it work with aaync functions

    • @RyanToronto
      @RyanToronto  3 месяца назад +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 3 месяца назад

      @@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  3 месяца назад +1

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

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

      @@RyanToronto thanks for the update, I appreciate