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 :/
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.
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?
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.
@@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.
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
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.
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?
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.
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
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.
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 ❤
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.
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 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
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.
Best use case of the react transition mechanism... I really love this... Thank you a lot.🎉🎉
Thank you! Glad you enjoyed it!
Appreciate the video. Nice to see startTransition solving some real world problems.
Thanks Erik!
This video helped me a ton
Really nice, didn't know that and really useful.
Thanks you! Glad you enjoyed it
Thanks Ryan ... great work as always 👍
Thanks!
Really good video
Thanks!
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 :/
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.
Great video. Thank's a lot.
Glad you liked it!
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?
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.
@@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.
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
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.
@@RyanToronto Yeah, it's not working. I gonna try, if I'll make it I'll let you know :)
Thanks
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?
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.
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
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.
@@RyanToronto cool, yea that makes sense, thanks!
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 ❤
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.
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
Sorry to hear about your issue. Do you have an example app or demo of your app anywhere?
@@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
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.
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?
Very unique solution with startTransition, how did you understand that it is necessary to use it
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.
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.