-
I have one route By default, what happens is that after the user successfully logs in on |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This is happening because you If possible, I recommend you to fetch before the navigation instead of dealing with the cache directly. |
Beta Was this translation helpful? Give feedback.
This is happening because you
mutate(key)
only triggers a revalidation if the useSWR hook using that same key is mounted, what you could do is to callawait mutate(key, fetcherForThatKey)
before the redirect and that will fill it with the new data. Another options you have here is to delete the cache for that key, you can do it withcache.delete(key)
andcache.delete(cache.serializeKey(key)[2])
(this last one removes the error key from the cache), this way when you go back to the profile nothing will be cached and a new request will be made.If possible, I recommend you to fetch before the navigation instead of dealing with the cache directly.