Exhaustive list of causes for app/layout re-render in production #71494
Unanswered
amplicity
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using next 14.2 and having a hard time understanding exactly what causes the
app/layoutto re-render. I'll paint the general picture of our app below.Root layout
app/layout
Most of our routes in our app are dynamic because they depend on user data, but they all use a shared layout,
app/app/layoutShared layout for all nested layouts
app/app/layoutI'm aware of the following scenarios causing a server component to re-render:
I have a case where we call a server action (a serverside function) from a client component. This client's closest layout is
/app/app/route1/[id]/layout. We have arouter.push(/app/app/route1/item/${itemId}). At this time, i'll sometimes see an app/layout re-render. The user has not signed in/signed out, so session should be unaffected (we're using next auth). Outside of number 3, which i've timed and does not appear to be the case, I am not seeing a reason this should cause anapp/layoutre-execution.The page it navigates to
/app/app/route1/item/[id]is 'use client'. The component does perform a server-side fetch, wrapped in an action, wrapped in a useEffect. The action is imported from a./actionsfile. The fetch has 'no-store', but from the documentation, this would appear to only cause a client-rerender.The only way I can consistently get the re-execution to happen is by changing the route mid-request. IE spamming a button or clicking 'back' as soon as the request flow starts. This definitely forces a re-execution. I have not seen anything about this behavior in documentation, so I'd like to understand both this behavior and any other expectations of re-execution with app/layout. I've read through this and this, but I'm not seeing this behavior described anywhere, I also would like to know exhaustively what causes app/layout to re-render, so we can be aware of it during development.
Beta Was this translation helpful? Give feedback.
All reactions