Change Log
Please visit the SWR release page for all history releases.
v2.0.3
Published on Sat Jan 28 2023.
Patches
- fix: parameters passed to subscribe is inconsistent with its declaration by @hong24 in https://github.com/vercel/swr/pull/2353
- fix: when inifinite key changes, should use cached pagesize instead of initialSize by @promer94 in https://github.com/vercel/swr/pull/2386
- fix: make compare function only compare data (#2375) by @Retrospection and @promer94 in https://github.com/vercel/swr/pull/2387 https://github.com/vercel/swr/pull/2389
fix: initial loading state should be false with revalidation is disabed by @promer94 in https://github.com/vercel/swr/pull/2382
fix: Ensure hydration matches the SSR result during streaming by @shuding in https://github.com/vercel/swr/pull/2391
Chores
- ci: only run release when tags pushed by @promer94 in https://github.com/vercel/swr/pull/2388
- unify
-
characters in README.md by @JanKaifer in https://github.com/vercel/swr/pull/2334
New Contributors
- @hong24 made their first contribution in https://github.com/vercel/swr/pull/2353
- @Retrospection made their first contribution in https://github.com/vercel/swr/pull/2387
- @JanKaifer made their first contribution in https://github.com/vercel/swr/pull/2334
Full Changelog: https://github.com/vercel/swr/compare/v2.0.2...v2.0.3
v2.0.2
Published on Thu Jan 26 2023.
Patches
- fix: delay revalidation if a key is already active and has error by @promer94 in https://github.com/vercel/swr/pull/2338
- fix: createCacheHelper type by @promer94 in https://github.com/vercel/swr/pull/2365
Chores
- release workflow by @huozhi in https://github.com/vercel/swr/pull/2374, https://github.com/vercel/swr/pull/2381, https://github.com/vercel/swr/pull/2383, https://github.com/vercel/swr/pull/2384, https://github.com/vercel/swr/pull/2385
Full Changelog: https://github.com/vercel/swr/compare/v2.0.1...v2.0.2
v2.0.1
Published on Wed Jan 18 2023.
In this patch release, we majorly improved typing support and SWR can infer the types based on the configuration.
- When the
suspense
option istrue
, the returneddata
will excludeundefined
and theisLoading
will always befalse
. - When the
fallbackData
option is provided, the returneddata
will be the same type offallbackData
, and theisLoading
will always befalse
.
Here's a demo for it:
https://user-images.githubusercontent.com/4800338/213288879-ffbeeeb5-aca5-4a65-8229-69fbf9b0bf70.mp4
What's Changed
- types: make FullConfiguration generic by @huozhi in https://github.com/vercel/swr/pull/2273
- type: enforce array literal as tuple by @promer94 in https://github.com/vercel/swr/pull/2283
- Improve type test by @promer94 in https://github.com/vercel/swr/pull/2289
- update bunchee to remove the extra target cli option by @huozhi in https://github.com/vercel/swr/pull/2298
- fix: useSWRMutation should always use the latest fetcher by @koba04 in https://github.com/vercel/swr/pull/2290
- types: conditional swr response by @huozhi in https://github.com/vercel/swr/pull/2301
- fix: types properites in exports fields by @koba04 in https://github.com/vercel/swr/pull/2341
- Update license year by @IcedMonk in https://github.com/vercel/swr/pull/2344
- feat: add all mutate options support to useSWRInfinite by @koba04 in https://github.com/vercel/swr/pull/2350
- ci: add publint to check packaging on CI by @koba04 in https://github.com/vercel/swr/pull/2363
New Contributors
- @IcedMonk made their first contribution in https://github.com/vercel/swr/pull/2344
Full Changelog: https://github.com/vercel/swr/compare/2.0.0...v2.0.1
2.0.0
Published on Fri Dec 09 2022.
Announcing SWR 2.0
We are excited to announce the release of SWR 2.0! The new version comes with a lot of improvements:
- New useSWRMutation hook
- Enhanced mutation and optimistic UI capabilities
- SWR DevTools
- Preload resource
- Improved React 18 support
And more!
Read our blog post and migration guide: https://swr.vercel.app/blog/swr-v2
What's Changed
- bugfix: make suspense and revalidateIfStale work together by @simowe in https://github.com/vercel/swr/pull/1851
- feat: support functional optimisticData by @huozhi in https://github.com/vercel/swr/pull/1861
- test: fix an act warning by @koba04 in https://github.com/vercel/swr/pull/1888
- breaking: Change the fetcher argument to be consistent with the passed key by @shuding in https://github.com/vercel/swr/pull/1864
- Keep all fields with one single key by @shuding in https://github.com/vercel/swr/pull/1863
- fix: wrong spell by @baojie223 in https://github.com/vercel/swr/pull/1902
- Update React 18 dependencies by @shuding in https://github.com/vercel/swr/pull/1824
- build(deps): bump minimist from 1.2.5 to 1.2.6 by @dependabot in https://github.com/vercel/swr/pull/1903
- type: make type inference simpler by @promer94 in https://github.com/vercel/swr/pull/1908
- type: fix type error on SWRConfig by @Himself65 in https://github.com/vercel/swr/pull/1913
- feat: Hook for remote mutations by @shuding in https://github.com/vercel/swr/pull/1450
- Add isFallback state by @shuding in https://github.com/vercel/swr/pull/1925
- build: output mutation cjs bundle with named exports by @huozhi in https://github.com/vercel/swr/pull/1926
- Add
isLoading
state and refactor the core by @shuding in https://github.com/vercel/swr/pull/1928 - Add
keepPreviousData
option by @shuding in https://github.com/vercel/swr/pull/1929 - types: drop legacy types by @huozhi in https://github.com/vercel/swr/pull/1930
- breaking: Throw error when using suspense on the server side without fallback in React 18 by @shuding in https://github.com/vercel/swr/pull/1931
- type: extends useConfig cache interface by @promer94 in https://github.com/vercel/swr/pull/1938
- remove mount check for react18 by @promer94 in https://github.com/vercel/swr/pull/1927
- lint: dont check unused vars with underscore prefix by @huozhi in https://github.com/vercel/swr/pull/1939
- test: upgrade to jest 28 by @huozhi in https://github.com/vercel/swr/pull/1942
- Fix cache types by @chibicode in https://github.com/vercel/swr/pull/1961
- Improved React 18 support by @promer94 in https://github.com/vercel/swr/pull/1962
- types: fix type regressions by @promer94 in https://github.com/vercel/swr/pull/1966
- fix: mutate args for useSWRInfinite hook by @sanjeev29 in https://github.com/vercel/swr/pull/1947
- build: import with-selector with extension from useESE by @huozhi in https://github.com/vercel/swr/pull/1967
- Bug fixes by @shuding in https://github.com/vercel/swr/pull/1968
- chore: Faster type checking by @shuding in https://github.com/vercel/swr/pull/1969
- fix: try fix codesanbox ci import error by @promer94 in https://github.com/vercel/swr/pull/1971
- Fix race conditions related to optimistic UI by @shuding in https://github.com/vercel/swr/pull/1970
- chore: Add test cases for mutate by @shuding in https://github.com/vercel/swr/pull/1976
- fix: Should always reset to the original data after mutating with optimistic data by @shuding in https://github.com/vercel/swr/pull/1982
- refactor: remove useless ref copy by @promer94 in https://github.com/vercel/swr/pull/1981
- chore: switch to pnpm and turborepo by @promer94 in https://github.com/vercel/swr/pull/1983
- fix: should only update cache when actually start new request by @promer94 in https://github.com/vercel/swr/pull/1986
- chore: save some bytes by @promer94 in https://github.com/vercel/swr/pull/1991
- fix: useSWRMutation - clear error after successful trigger (#1973) by @anirudh1713 in https://github.com/vercel/swr/pull/1995
- Fix typo: getSWRCacahe -> getSWRCache by @sdornan in https://github.com/vercel/swr/pull/2000
- build: do not abort on watch mode when ts erroring by @huozhi in https://github.com/vercel/swr/pull/1992
- chore: add engine field to limit pnpm version by @huozhi in https://github.com/vercel/swr/pull/1990
- test: add test case for #1974 by @promer94 in https://github.com/vercel/swr/pull/2005
- fix: Adding debounce for autocomplete-suggestions example by @Walkeryr in https://github.com/vercel/swr/pull/2017
- BREAKING: rename SWRConfig.default to SWRConfig.defaultValue by @huozhi in https://github.com/vercel/swr/pull/2023
- feat: support functional swr context config by @huozhi in https://github.com/vercel/swr/pull/2024
- test: fix all act warnings by @koba04 in https://github.com/vercel/swr/pull/2031
- feat: add preload function by @koba04 in https://github.com/vercel/swr/pull/2026
- fix: Avoid preloading the resource multiple times by @shuding in https://github.com/vercel/swr/pull/2036
- fix: isLoading and isValidating should always respect cache value by @promer94 in https://github.com/vercel/swr/pull/2048
- Fix ts type generation by @huozhi in https://github.com/vercel/swr/pull/2038
- feat: mutate filter by @huozhi in https://github.com/vercel/swr/pull/1989
- Fix typos by @hiro0218 in https://github.com/vercel/swr/pull/2052
- feat: add DevTools hook by @koba04 in https://github.com/vercel/swr/pull/2016
- Use consistent typing imports by @huozhi in https://github.com/vercel/swr/pull/2061
- Upgrading use-sync-external-store lib by @sanjaiyan-dev in https://github.com/vercel/swr/pull/2063
- Revert swr config generic by @huozhi in https://github.com/vercel/swr/pull/2065
- Fix: raf return type by @huozhi in https://github.com/vercel/swr/pull/2074
- Remove unused info from dummy package.json by @huozhi in https://github.com/vercel/swr/pull/2083
- Use pnpm workspace by @huozhi in https://github.com/vercel/swr/pull/2085
- bump typescript and apply nodenext module resolution by @huozhi in https://github.com/vercel/swr/pull/2084
- Chore: Typos and grammar by @AllanOliveiraM in https://github.com/vercel/swr/pull/2094
- chore: add basic tsdoc by @promer94 in https://github.com/vercel/swr/pull/2089
- types: add generic for SWRInfiniteKeyLoader by @jason89521 in https://github.com/vercel/swr/pull/2104
- fix: add swr/internal to paths by <a href="https://github.com/jason89521" target="blank" rel="noopener">@jason89521</a> in https://github.com/vercel/swr/pull/2105
- type: make tsconfig simpler and fix type error by @promer94 in https://github.com/vercel/swr/pull/2115
- chore: exclude .tsbuildinfo from files, reduce install size by @promer94 in https://github.com/vercel/swr/pull/2119
- Reorder exports conditions by @huozhi in https://github.com/vercel/swr/pull/2130
- Upgrade bunchee by @huozhi in https://github.com/vercel/swr/pull/2132
- Bump typescript and assemble pnpm scripts by @huozhi in https://github.com/vercel/swr/pull/2133
- chore: add github actions reporter by @promer94 in https://github.com/vercel/swr/pull/2131
- Dedupe installed swc by @huozhi in https://github.com/vercel/swr/pull/2136
- test: add a test for preload API in effects by @koba04 in https://github.com/vercel/swr/pull/2138
- test: add more isLoading tests for the case a key is null or an error by @koba04 in https://github.com/vercel/swr/pull/2141
- ci: use action/setup-node built-in pnpm cache and bump to node16 by @promer94 in https://github.com/vercel/swr/pull/2142
- test: add tests for dependency collection by @koba04 in https://github.com/vercel/swr/pull/2140
- chore: bump dev deps by @huozhi in https://github.com/vercel/swr/pull/2143
- memoize config values to avoid frequent context propagation by @gnoff in https://github.com/vercel/swr/pull/2149
- Bundle types into one file by @huozhi in https://github.com/vercel/swr/pull/2150
- Revert target option by @huozhi in https://github.com/vercel/swr/pull/2151
- chore: fix missing husky warning by @huozhi in https://github.com/vercel/swr/pull/2160
- Remove downlevelIteration and traverse iterator manually by @huozhi in https://github.com/vercel/swr/pull/2181
- fix: re-render when returned data and fallbackData is the same and keepPreviousData is enabled by @koba04 in https://github.com/vercel/swr/pull/2169
- breaking: Change the error broadcasting behavior in mutations and add
throwOnError
option by @shuding in https://github.com/vercel/swr/pull/2182 - docs: Add JSDoc comments to useSWRMutation by @shuding in https://github.com/vercel/swr/pull/2183
- type: export MutationFetcher by @ssssota in https://github.com/vercel/swr/pull/2184
- Bump bundler by @huozhi in https://github.com/vercel/swr/pull/2187
- resolve swr internal imports as external by @huozhi in https://github.com/vercel/swr/pull/2225
- test: update tests alias to swr subpath exports by @huozhi in https://github.com/vercel/swr/pull/2243
- feat: support functional rollbackOnError by @huozhi in https://github.com/vercel/swr/pull/2242
- Update build target to es2018 by @shuding in https://github.com/vercel/swr/pull/2249
- Fix missing esmodule mark in cjs build by @huozhi in https://github.com/vercel/swr/pull/2251
- fix: pass null fetcher to middleware by @koba04 in https://github.com/vercel/swr/pull/2240
New Contributors
- @simowe made their first contribution in https://github.com/vercel/swr/pull/1851
- @baojie223 made their first contribution in https://github.com/vercel/swr/pull/1902
- @Himself65 made their first contribution in https://github.com/vercel/swr/pull/1913
- @chibicode made their first contribution in https://github.com/vercel/swr/pull/1961
- @sanjeev29 made their first contribution in https://github.com/vercel/swr/pull/1947
- @sdornan made their first contribution in https://github.com/vercel/swr/pull/2000
- @Walkeryr made their first contribution in https://github.com/vercel/swr/pull/2017
- @hiro0218 made their first contribution in https://github.com/vercel/swr/pull/2052
- @sanjaiyan-dev made their first contribution in https://github.com/vercel/swr/pull/2063
- @AllanOliveiraM made their first contribution in https://github.com/vercel/swr/pull/2094
- @jason89521 made their first contribution in https://github.com/vercel/swr/pull/2104
- @gnoff made their first contribution in https://github.com/vercel/swr/pull/2149
- @ssssota made their first contribution in https://github.com/vercel/swr/pull/2184
Full Changelog: https://github.com/vercel/swr/compare/1.2.2...2.0.0
2.0.0-rc.3
Published on Mon Nov 28 2022.
What's Changed
- Fix missing esmodule mark in cjs build by @huozhi in https://github.com/vercel/swr/pull/2251
- fix: pass null fetcher to middleware by @koba04 in https://github.com/vercel/swr/pull/2240
Full Changelog: https://github.com/vercel/swr/compare/2.0.0-rc.1...2.0.0-rc.3