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?
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?