⬆ ️ deps: Bump swr from 1.2.1 to 1.3.0
Bumps swr from 1.2.1 to 1.3.0.
Release notes
Sourced from swr's releases.
1.3.0
What's Changed
- type: fix type error on SWRConfig by
@Himself65
in #1913- chore: update React 18 dependencies by
@shuding
in #1824- test: fix an act warning by
@koba04
in #1888- feat: support functional optimisticData by
@huozhi
in #1861- bugfix: make suspense and revalidateIfStale work together by
@simowe
in #1851Full Changelog: https://github.com/vercel/swr/compare/1.2.2...1.3.0
1.2.2
Highlights of This Release
populateCache
Option Now Supports FunctionWe added better Optimistic UI support in v1.2.0. However, what if your API is only returning a subset of the data (such as the mutated part), that can be populated into the cache? Usually, an extra revalidation after that mutation is needed. But now you can also use a function as
populateCache
to transform the mutate result into the full data:await mutate(addTodo(newTodo), { optimisticData: [...data, newTodo], rollbackOnError: true, populateCache: (addedTodo, currentData) => { // `addedTodo` is what the API returns. It's not // returning a list of all current todos but only // the new added one. // In this case, we can transform the mutate result // together with current data, into the new data // that can be updated. return [...currentData, addedTodo]; }, // Since the API already gives us the updated information, // we don't need to revalidate here. revalidate: false, });
The new definition:
populateCache?: boolean | ((mutationResult: any, currentData: Data) => Data)
Here is a demo for it: https://codesandbox.io/s/swr-basic-forked-hi9svh
Bug Fixes
What's Changed
- refactor: revalidateIfStale has an effect on updates, not only mounting by
@koba04
in vercel/swr#1837- fix: reset stale unmountedRef in suspense by
@promer94
in vercel/swr#1843
... (truncated)
Commits
-
9b9771e
1.3.0 -
6bb79f7
type: fix type error on SWRConfig (#1913) -
04b8302
build(deps): bump minimist from 1.2.5 to 1.2.6 (#1903) -
8993bab
Update React 18 dependencies (#1824) -
39c3a98
test: fix an act warning (#1888) -
7cef58d
feat: support functional optimisticData (#1861) -
1ae8cc6
bugfix: make suspense and revalidateIfStale work together (#1851) -
f24c621
1.2.2 -
baaafc2
feat: SupportpopulateCache
as a function (#1818) -
ef400ea
test: add a test for the behavior of revalidateOnMount when the key has been ... - Additional commits viewable in compare view