-
Hi, I am working on Jetpack Compose version of this library. Currently I am trying to adapt 1.0.0 changes to my current work. I am a bit confused about adding Currently I think it is not clear how this both parameters works together. Also - there is no information in docs if previous // How would that work? It's confusing
useSWR(key, fetcher, {
revalidateIfStale: false,
revalidateOnMount: true
}) In my library I'm thinking about removing |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
The So basically it works like this:
|
Beta Was this translation helpful? Give feedback.
-
Thanks! It would be great to include this in docs |
Beta Was this translation helpful? Give feedback.
-
request while component mount at the first time, then cache data, not request anymore whether cache is stale or not.
request while component is mounted at the first time and cache.
always request when component is mounted
not request. Maybe you can use SSR fallback immutable data? have a try
|
Beta Was this translation helpful? Give feedback.
The
revalidateOnMount
option (default to undefined) is used to force override the SWR revalidation behavior on mounting. The newrevalidateIfStale
(default to true) means if SWR should revalidate on mounting if the cache exists.So basically it works like this:
recalidateOnMount
defined? Start request if it’strue
, stop iffalse
.revalidateIfStale
true
? If it is, start the request.