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
fetchUser
and app/lib/purhcaseActions.ts providesfetchPurchases
server actions.In
[userId]/layout.tsx
I setup the user context like this--with UserProvider a
use client
component --In
[userId]/purchases/page.tsx
I mount the main component wrapped in SWRConfigand the main component which uses
useSWR
--Now every
refreshInterval
, whenfetchPurchases
is called in the final client component, thefetchUser
in 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
fetchUser
is not called for everyfetchPurchase
periodic execution?Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions