Correct use with NextJS::layout to prevent layout refreshes ? #4169
Unanswered
prabuvenkat-gh
asked this question in
Q&A
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.
-
Hei!
I have the following setup:
app/lib/userActions.ts provides
fetchUserand app/lib/purhcaseActions.ts providesfetchPurchasesserver actions.In
[userId]/layout.tsxI setup the user context like this--with UserProvider a
use clientcomponent --In
[userId]/purchases/page.tsxI mount the main component wrapped in SWRConfigand the main component which uses
useSWR--Now every
refreshInterval, whenfetchPurchasesis called in the final client component, thefetchUserin layout.tsx i executed.Is this expected? My understandng of how appRouter::layout.tsx is that all child pages (recursively) retain a parent layout which will not be refreshed when the child client components get a refresh.
Or, am I missing something? How can I ensure
fetchUseris not called for everyfetchPurchaseperiodic execution?Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions