Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback for “Cache” - Clear Cache function / example #571

Open
SimonKraushaar opened this issue Mar 19, 2024 · 0 comments
Open

Feedback for “Cache” - Clear Cache function / example #571

SimonKraushaar opened this issue Mar 19, 2024 · 0 comments

Comments

@SimonKraushaar
Copy link

I have been receiving stale error states from SWR when navigating back to a page after a login ( SWR reports an error, page redirects, using logs in setting tokens, and then navigates back to the page, the error is still set and displays an error until the SWR fetch result has been completed, this can take a second or so where my "Not Authorized" page is present until its refreshed.)

To rectify this the only way i can seem able to do this is clear the cache using mutate(() => true, undefined, { revalidate: false }); to initiate a "new" session.

But it seems to me that errors should not be cached anyway? if a previous error exists in the cache, should useSWR immediately re-fetch, clearing the cache and setting {isLoading } - if not, is there a flag I am missing that would force such a thing on the hook itself?

Perhaps I am miss understanding the flow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant