You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're working on an app that has pages load either CSR or SSR using Next.js. I noticed that when I provide initialData to my useSWR hook and it's SSRed it works all fine. Now if the user is navigated to the same page through CSR and initialData is provided it ignores the initialData and uses the cache instead. I assume that this initialData should have consistent behaviour for both SSR and CSR, or am I wrong to assume that?
I haven't tried manually mutating the object such that it revalidates. I did check that, when I remove the initialData field it seems to work fine. Not completely sure how solid that solution is.
It'd be great to get some feedback on this!
Cheers
The text was updated successfully, but these errors were encountered:
Having thought about it for a bit, they don’t behave different at all.. Our use case gets a ‘fresh’ CSR page that should be filled with ‘fresh’ SWR data. Now, commonly client-side the cache should hold the most recent version, whereas we have an ‘empty’ page.
On CSR it’s likely that it already had responses, those should be preferred over initialData.
There’s two ways I can go about this now:
Clear the cache somehow and have swr refetch by itself;
Figure out some logic on which I can call trigger to refresh the data;
@feclist could you try the solution posted in #284 (comment) ?
Will close this issue as it seems to be reoslved with swr@beta, feel free to comment or reopen if you have any further issues
Hi all,
We're working on an app that has pages load either CSR or SSR using Next.js. I noticed that when I provide initialData to my
useSWR
hook and it's SSRed it works all fine. Now if the user is navigated to the same page through CSR and initialData is provided it ignores the initialData and uses the cache instead. I assume that this initialData should have consistent behaviour for both SSR and CSR, or am I wrong to assume that?I haven't tried manually mutating the object such that it revalidates. I did check that, when I remove the initialData field it seems to work fine. Not completely sure how solid that solution is.
It'd be great to get some feedback on this!
Cheers
The text was updated successfully, but these errors were encountered: