Handling RSC Errors in Next.js

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 พ.ย. 2024

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

  • @vickonsscope6477
    @vickonsscope6477 6 หลายเดือนก่อน +6

    Best use case of the react transition mechanism... I really love this... Thank you a lot.🎉🎉

    • @RyanToronto
      @RyanToronto  6 หลายเดือนก่อน

      Thank you! Glad you enjoyed it!

  • @erikplachta
    @erikplachta 6 หลายเดือนก่อน +2

    Appreciate the video. Nice to see startTransition solving some real world problems.

    • @RyanToronto
      @RyanToronto  6 หลายเดือนก่อน +1

      Thanks Erik!

  • @OrkhanFattayev
    @OrkhanFattayev 27 วันที่ผ่านมา

    This video helped me a ton

  • @stevebendersky2056
    @stevebendersky2056 2 หลายเดือนก่อน

    Really nice, didn't know that and really useful.

    • @RyanToronto
      @RyanToronto  2 หลายเดือนก่อน

      Thanks you! Glad you enjoyed it

  • @haydenpitout5151
    @haydenpitout5151 6 หลายเดือนก่อน

    Thanks Ryan ... great work as always 👍

  • @talhaibnemahmud
    @talhaibnemahmud 6 หลายเดือนก่อน +1

    Really good video

  • @oscarljimenez5717
    @oscarljimenez5717 7 หลายเดือนก่อน +2

    Great video like always :)
    One question. What's the standard for showing clean errors on the console? Using a logger like "pino"?
    But then i can't throw an error that my error boundary can catch :/

    • @RyanToronto
      @RyanToronto  7 หลายเดือนก่อน +1

      Thanks, glad you enjoyed it!
      Yah I think pino is great for logging. That said I'd still throw the error and have the error boundary catch it, but maybe also use pino right before you throw the error.

  • @mehrabmahmudpur6984
    @mehrabmahmudpur6984 6 หลายเดือนก่อน

    Great video. Thank's a lot.

    • @RyanToronto
      @RyanToronto  6 หลายเดือนก่อน

      Glad you liked it!

  • @tauhid97k
    @tauhid97k 5 หลายเดือนก่อน

    Thanks. Can you make a video on setting cookies from a separate backend in the next.js server action? So, When I use server action and set credentials: "include" it doesn't work. This is because it's happening on the server. How can I forward the cookies in the browser to that separate API/backend server from server action?

    • @RyanToronto
      @RyanToronto  5 หลายเดือนก่อน +1

      Great question. You can use Next's built in cookies() function to read the cookies in your server action and then pass them into the fetch request your action is making to your backend.

    • @tauhid97k
      @tauhid97k 5 หลายเดือนก่อน

      @@RyanToronto I've tried this and several other methods but it's not consistent or maybe I don't quite understand the situation here. From the client side credentials: "include" works as expected. So I thought with your amazing explanation I could understand better. But Thanks. I'll keep trying.

  • @bojanraguz369
    @bojanraguz369 3 หลายเดือนก่อน

    What to do in a case when the user clicks on a route "/throws-sometimes" that's included in navbar?
    Can the error be reset via clicking on a link to the route within navbar? e.g.
    Throws sometimes

    • @RyanToronto
      @RyanToronto  3 หลายเดือนก่อน

      I haven't tried it, but I wonder if it just works? If not, my first thought was you'd have to somehow get the reset into the nav bar so the error could be dismissed. Let me know what you come up with, I'd be very interested to know how you went about solving this type of problem.

    • @bojanraguz369
      @bojanraguz369 3 หลายเดือนก่อน

      @@RyanToronto Yeah, it's not working. I gonna try, if I'll make it I'll let you know :)
      Thanks

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

    Is router.refresh() by default wrapped in a transition under the hood?
    Is that why reset() executes first? So, is Router.refresh() considered an asynchronous while reset() remains sync, unless we put both together in a transition and we force both to be completed before continuing?

    • @RyanToronto
      @RyanToronto  6 หลายเดือนก่อน +1

      Yup, router.refresh uses a transition under the hood.
      We need to put both the reset and the router.refresh in the transition so React knows to not reset until the refresh is complete. We're telling React we'd like to transition to a state where the router is refreshed and the error boundary is reset. React won't apply the state update until those two things are ready.
      Another way of saying this: Putting them inside the transition tells React that they need to happen together.

  • @luisllaboj
    @luisllaboj 4 หลายเดือนก่อน

    What would happen if wrap a transition in a transition? The outer transition holds a state for the inner transition or are they batched together or “unwrapped” like it was a promise passed to a promise constructor? lol idk if that makes sense

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

      Great question! Transitions that wrap transitions are very common and I think saying they are "batched" is the right way of thinking about it. If a transition is inside another transition then neither state update will apply until they are both ready. In other words the state updates happen at the same time for all nested transitions.

    • @luisllaboj
      @luisllaboj 4 หลายเดือนก่อน

      @@RyanToronto cool, yea that makes sense, thanks!

  • @bideshbanerjee5506
    @bideshbanerjee5506 6 หลายเดือนก่อน

    Hello Ryan you are the only one who talks deep about RSC.
    I just want to know one thing that suppose for a particular page there are 4 - 5 components and an user changes or updates something in a component with server action then the whole json representation of every component of that page will get send by the server, is that how it works ?? and if it is, how optimal is that approach or it works differently ?? I know it's lot to ask...but will appreciate a video or response
    Thank you ❤

    • @RyanToronto
      @RyanToronto  6 หลายเดือนก่อน

      Thank you! To answer your question it really depends on the framework you are using and how your app and action is setup. If you're using Next.js with server actions you'll most likely want to call the built-in `revalidate()` function to update any components on the page.

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

    we have an issue in some pages we have a conditional display based on the url query and we need on each query change to reload to get the updated data 😢
    any idea please hmmm even with parallel routes I need to noStore() to revalidate the data eeeeeh

    • @RyanToronto
      @RyanToronto  6 หลายเดือนก่อน

      Sorry to hear about your issue. Do you have an example app or demo of your app anywhere?

    • @0xtz_
      @0xtz_ 6 หลายเดือนก่อน

      @@RyanToronto it's a private code that I can't share
      but it's a
      server component takes an id in the query and display the needed component
      I can provide a basic example of you have a discord or something hhh

  • @TfMukles
    @TfMukles 6 หลายเดือนก่อน

    make a video on refresh token in nextjs. I am facing the issues. In nextjs layout and page is stream simultaneously can you please make a video.

    • @RyanToronto
      @RyanToronto  6 หลายเดือนก่อน

      Hey there, would love to! Do you have an example app, mockups, or any code you can share so I can better understand the app and problem?

  • @nick-ui
    @nick-ui 6 หลายเดือนก่อน

    Very unique solution with startTransition, how did you understand that it is necessary to use it

    • @erikplachta
      @erikplachta 6 หลายเดือนก่อน +1

      The refresh wasn’t happening because reset was executed before refresh had time to complete.
      - Router.Refresh is refreshing the connection to the server.
      - Reset restarts the component.
      No async option on refresh.

    • @RyanToronto
      @RyanToronto  6 หลายเดือนก่อน +1

      Exactly what @erikplachta said! Since you want refresh and reset to happen at the same time they both need to be wrapped in a transition.