Replies: 9 comments 7 replies
-
I am having a little bit of trouble understanding how the error handling works with A couple things I noticed:
These two behaviors are different from |
Beta Was this translation helpful? Give feedback.
-
Would it be possible to use an ASYNC cache ? For example on React Native, we might want to cache the data using the AsyncStorage so that when the user doesn't have an internet connection, SWR would use the cached version from AsyncStorage. |
Beta Was this translation helpful? Give feedback.
-
What About Partial Update During PATCH Request. It Fetch All Data After Patching . So How To Fetch Only That Data Which Is PATCHED During Request. |
Beta Was this translation helpful? Give feedback.
-
Maybe there is an example somewhere that I haven't found yet, but was wondering how would one implement the idea of Mutating based on current data using the new |
Beta Was this translation helpful? Give feedback.
-
Is it possible to share |
Beta Was this translation helpful? Give feedback.
-
It'd be great if the |
Beta Was this translation helpful? Give feedback.
-
@shuding @huozhi Thank you so much for your work guys! We are going to start using the 2.0.0-rc.0 version in our project today and we'll be back with any possible feedback. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Could someone provide steps to install swr 2.0.0 release candidates on react native project ? my project runs on bare and expo, i tried to install it with yarn add vercel/swr #2.0.0-rc.3 but i'm getting: |
Beta Was this translation helpful? Give feedback.
-
SWR 2.0 coming soon, and this is the first beta version!
Keep in mind that APIs might still change until the stable release. Documentation will also be updated once stable.
Highlights
useSWRMutation — dedicated API for remote mutations, e.g. POST (#1450)
Added in #1450, the new
useSWRMutation
hook covers all the use cases of:isValidating
but for mutations.Here's a quick example of how it looks:
In this example, the "fetcher", which is
sendRequest
, will receive the value{ username: 'johndoe' }
as thearg
from the second parameter. The request will only be triggered when clicking the button.The new
useSWRMutation
hook is actually more powerful than this, it also supports:useSWR
useSWR
after mutation finishesMore examples to come.
Breakings
Fetcher no longer accepts multiple arguments (#1864)
Previously, if the
key
is an array, the values will be passed to thefetcher
function as arguments separately. In 2.0, thekey
will always be passed to thefetcher
as is.Before:
After 2.0.0:
Internal structure of the cached data (#1863)
This change affects the code that directly reads/writes to the cache, or provides a cache preset. For example if you have something like
cache.set(key, value)
, you'll have to update your code.Previously, the cached value of
key
will be the associateddata
, so this was guaranteed:And we keep other states (
error
,isValidating
) with a special, prefixed key. Something like'$err$' + key
.Since 2.0.0, the internal structure will be an object that holds all the current states:
What's Changed
New Contributors
Full Changelog: 1.2.2...2.0.0-beta.0
This discussion was created from the release 2.0.0-beta.0.
Beta Was this translation helpful? Give feedback.
All reactions