You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The useSWRMutation makes lazy querying a piece of cake, it works like a charm. However, I'm wondering how I could hit the cache first and then revalidate over the network. At the moment every mutation will go over the network.
The idea is that useSWRMutation.trigger hits the cache first (when the key is already known in the cache) and then revalidates over the network, see this codesandbox for more context.
Use cases
A search field that only triggers the request when clicking "submit" or "search". When entering the same search query, that is already known in the cache, I expect to get a cache-hit first and the network revalidation should kick in.
A table that only starts requesting data when clicking a trigger button, the table uses pagination and passes the current page to the useSWRMutation hook. Revisiting page 1 (after already) should hit the cache first and then revalidate.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Question
The
useSWRMutation
makes lazy querying a piece of cake, it works like a charm. However, I'm wondering how I could hit the cache first and then revalidate over the network. At the moment every mutation will go over the network.The idea is that
useSWRMutation.trigger
hits the cache first (when the key is already known in the cache) and then revalidates over the network, see this codesandbox for more context.Use cases
Links
Beta Was this translation helpful? Give feedback.
All reactions