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
Here the cache will be immediately updated to user (optimistic value), and then a request (mutation) is started via patchUser(user) and the result will be written to the cache. If that mutation fails, the original result will be rolled back safely. And after all those finishes, a revalidation will start to fetch the latest value.
You can do the same for the global mutate, just remember to pass the key.
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.
-
Highlights of This Release
Dedicated API for Optimistic Updates with Auto Rollback on Error
There are now some new options in
mutate
:Here the cache will be immediately updated to
user
(optimistic value), and then a request (mutation) is started viapatchUser(user)
and the result will be written to the cache. If that mutation fails, the original result will be rolled back safely. And after all those finishes, a revalidation will start to fetch the latest value.You can do the same for the global
mutate
, just remember to pass the key.Here's an example: https://codesandbox.io/s/swr-basic-forked-k5hps.
What's Changed
Full Changelog: 1.1.2...1.2.0-beta.0
This discussion was created from the release 1.2.0-beta.0.
Beta Was this translation helpful? Give feedback.
All reactions