Data only refeshs after reloading the page #790
Answered
by
NikRoe
PeetThesing
asked this question in
Web
-
Hi there, we encountered a problem: Our data only updates after a complete reload of the page. We think this problem exists since the implementation of the bookmarks and moving the data fetching to the _app.js. Here is our PR We tried using mutate, but that doesn't seem to help. We appreciate any help. |
Beta Was this translation helpful? Give feedback.
Answered by
NikRoe
Dec 5, 2023
Replies: 1 comment 2 replies
-
Hi there, I got it working by calling I'll talk about this with @onemanwenttomow soonish and then we'll come back to you. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there,
the one and only @onemanwenttomow was able to find a better solution!
Your approach with using
mutate
was the absolute right one, however, you need to make a very small adjustment to it:in your
handleDelete
inSnippetDetailsPage
you need to add a slash to the string.The reason behind this is that this string needs to be identical to the URL string of your fetch in the
_app.js
to actually case swr to revalidate the data.In your
createSnippet
inFormPage
you can callmutate()
without passing an argument to it.Since you destructure it from the return of
useSWR("/api/snippets");
it will always revalidate the URL you specified here.Hope this already make…