Cache problem when put in initialData when using useSWR #990
Unanswered
jonsoku-dev
asked this question in
Q&A
Replies: 1 comment
-
Hi, for what I know :
|
Beta Was this translation helpful? Give feedback.
0 replies
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.
Uh oh!
There was an error while loading. Please reload this page.
-
I found a bug that when using the default useSWR, initialData is not cached. So, I solved the initial cache storage problem by using the following custom useSwr.
However, when I ran global mutate on another page, I found out that it was not being refetched from useSWR in original page.
[LIST PAGE] localhost:3000/post
server_api_url/post", {initialData: initialPosts })[CREATE PAGE] localhost:3000/post/create
server_api_url/post")[LIST PAGE] localhost:3000/post
I am temporarily using
revalidateOnMount: true
. When this is used, when a page is moved due torouter.push
, the list page makes an API request again.But this is not the ultimate solution I want.
The reason is that when entering the LIST page for the first time, API called from
getStaticProps
, and an additional API called again throughrevalidateOnMount
.Is there any solution for this?
custom useSwr
Beta Was this translation helpful? Give feedback.
All reactions