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

Revalidation even if data is already cached & revalidateOnFocus is false. #257

Closed
omerman opened this issue Feb 12, 2020 · 2 comments
Closed

Comments

@omerman
Copy link

omerman commented Feb 12, 2020

Hi, First of all thanks for this rocking lib. Im exploring it these days, its awesome.

Now to my issue,
I'm rendering a component that uses useSWR like such -> useSWR('key', fetcher).
After the component unmounts, and re-mounts again, Im noticing that the useSWR does infact bring back the cached results, but it also triggers a revalidation.

  1. Is this the expected behavior?
  2. If so, can you please supply a flag indication to cancel it? locally & globally

Thanks, Looking forward for your response

@sergiodxa
Copy link
Contributor

That is an intended behavior, the name of the library comes from the idea to first show stale data then revalidate it against the API and update it to show the correct data (stale-while-revalidate aka SWR).

There is a PR #225 intended to add a flag to set SWR to don't revalidate the cache on mount and let you manually do it if you want (it will still fetch it if it wasn't already provided with the initialData option).

@omerman
Copy link
Author

omerman commented Feb 13, 2020

Thank you, It took me a while to grasp the concept :) Thanks again for your quick response.

@omerman omerman closed this as completed Feb 13, 2020
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

2 participants