Why does layout rerender on redirect() but not on router.push() #67664
Replies: 1 comment 2 replies
-
|
Also keep in mind that by default, Next.js automatically caches the returned values of fetch in the Data Cache on the server, so if the response is found, it's returned immediately and doesn't initiate a new request. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've prepared a small app that has 3 buttons:
<Link />router.push()redirect()On initial render '!!! render' is logged to the console, this is expected.
But only when clicking the button that uses redirect() the message is logged again.
Why is this? Why does the server action that uses redirect() cause the root layout to rerender?
https://stackblitz.com/edit/stackblitz-starters-9z86me?file=app%2Flayout.tsx
Why is this a problem for me?
If I data fetch in my layout, using redirect() would cause the data to be refetched every time its called.
Beta Was this translation helpful? Give feedback.
All reactions