Skip to content

reavalidateOnMount and revalidateIfStale #1400

Answered by shuding
burnoo asked this question in General
Discussion options

You must be logged in to vote

The revalidateOnMount option (default to undefined) is used to force override the SWR revalidation behavior on mounting. The new revalidateIfStale (default to true) means if SWR should revalidate on mounting if the cache exists.

So basically it works like this:

  1. A SWR hook mounts
  2. Is recalidateOnMount defined? Start request if it’s true, stop if false.
  3. Is there existing cache? If there isn’t, start the request.
  4. Is revalidateIfStale true? If it is, start the request.

Replies: 3 comments 7 replies

Comment options

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

@shuding
Comment options

Answer selected by burnoo
Comment options

You must be logged in to vote
4 replies
@shuding
Comment options

@dorgamliel1
Comment options

@koba04
Comment options

@marmotgary
Comment options

Comment options

You must be logged in to vote
1 reply
@sb007ty
Comment options

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