Skip to content
Discussion options

You must be logged in to vote

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 call await 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 with cache.delete(key) and cache.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.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@roddyyaga
Comment options

@agjs
Comment options

Answer selected by roddyyaga
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants