Handling RSC Errors in Next.js

  Рет қаралды 2,407

Ryan Toronto

Ryan Toronto

Күн бұрын

Пікірлер: 35
@vickonsscope6477
@vickonsscope6477 5 ай бұрын
Best use case of the react transition mechanism... I really love this... Thank you a lot.🎉🎉
@RyanToronto
@RyanToronto 5 ай бұрын
Thank you! Glad you enjoyed it!
@erikplachta
@erikplachta 5 ай бұрын
Appreciate the video. Nice to see startTransition solving some real world problems.
@RyanToronto
@RyanToronto 5 ай бұрын
Thanks Erik!
@stevebendersky2056
@stevebendersky2056 Ай бұрын
Really nice, didn't know that and really useful.
@RyanToronto
@RyanToronto Ай бұрын
Thanks you! Glad you enjoyed it
@haydenpitout5151
@haydenpitout5151 5 ай бұрын
Thanks Ryan ... great work as always 👍
@RyanToronto
@RyanToronto 5 ай бұрын
Thanks!
@talhaibnemahmud
@talhaibnemahmud 5 ай бұрын
Really good video
@RyanToronto
@RyanToronto 5 ай бұрын
Thanks!
@mehrabmahmudpur6984
@mehrabmahmudpur6984 5 ай бұрын
Great video. Thank's a lot.
@RyanToronto
@RyanToronto 5 ай бұрын
Glad you liked it!
@bideshbanerjee5506
@bideshbanerjee5506 5 ай бұрын
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 4 ай бұрын
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.
@oscarljimenez5717
@oscarljimenez5717 5 ай бұрын
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 5 ай бұрын
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.
@nick-ui
@nick-ui 5 ай бұрын
Very unique solution with startTransition, how did you understand that it is necessary to use it
@erikplachta
@erikplachta 5 ай бұрын
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 5 ай бұрын
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.
@tauhid97k
@tauhid97k 4 ай бұрын
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 4 ай бұрын
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 4 ай бұрын
@@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 Ай бұрын
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 Ай бұрын
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 Ай бұрын
@@RyanToronto Yeah, it's not working. I gonna try, if I'll make it I'll let you know :) Thanks
@TfMukles
@TfMukles 5 ай бұрын
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 5 ай бұрын
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?
@luisllaboj
@luisllaboj 3 ай бұрын
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 3 ай бұрын
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 3 ай бұрын
@@RyanToronto cool, yea that makes sense, thanks!
@luisllaboj
@luisllaboj 5 ай бұрын
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 5 ай бұрын
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.
@0xtz_
@0xtz_ 5 ай бұрын
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 5 ай бұрын
Sorry to hear about your issue. Do you have an example app or demo of your app anywhere?
@0xtz_
@0xtz_ 5 ай бұрын
@@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
Why you can't set cookies in Server Components
10:58
Ryan Toronto
Рет қаралды 9 М.
Where should this component run?
9:01
Ryan Toronto
Рет қаралды 1,7 М.
LIFEHACK😳 Rate our backpacks 1-10 😜🔥🎒
00:13
Diana Belitskay
Рет қаралды 3,9 МЛН
Man Mocks Wife's Exercise Routine, Faces Embarrassment at Work #shorts
00:32
Fabiosa Best Lifehacks
Рет қаралды 4,7 МЛН
Поветкин заставил себя уважать!
01:00
МИНУС БАЛЛ
Рет қаралды 6 МЛН
Refresh React Server Components
10:10
Ryan Toronto
Рет қаралды 4,6 М.
Asset loading in React
11:11
Ryan Toronto
Рет қаралды 1,8 М.
JavaScript Error Handling: 5 Things You Aren’t Thinking About!
14:42
Why I use Zod with Server Actions
15:21
Ryan Toronto
Рет қаралды 13 М.
Master NextJS Error Handling in 10 Minutes
9:49
Josh tried coding
Рет қаралды 50 М.
Error Handling in Server Actions Next.js (Incl. Toasts!)
10:30
My Problem with Next.js Server Actions
10:13
James Q Quick
Рет қаралды 17 М.
React's new cache function
10:14
Ryan Toronto
Рет қаралды 10 М.
LIFEHACK😳 Rate our backpacks 1-10 😜🔥🎒
00:13
Diana Belitskay
Рет қаралды 3,9 МЛН