Highlights of This Release
Use the Latest Fetcher Function
SWR will now use the latest fetcher function passed to the hook, when sending the request. Previously it uses the initial snapshotted fetcher.
Avoid Unnecessary Auto Revalidations
When refocusing on the window with state changes (like clicking a button that changes the SWR key immediately), SWR now avoids revalidations if they're not necessary. Details can be found in #1720.
New Types for useSWRInfinite
Two types for useSWRInfinite
are added: SWRInfinteHook
and SWRInfinteKeyLoader
. You can use them to type the hook and the getKey
function.
New populateCache
option for mutate
A new option to control if the mutation data should be written to the cache. You can find the details in #1729.
What's Changed
- Make polyfill for
requestAnimationFrame
more robust by @thomaspaulmann in #1707 - type(infinite): export SWRInfinteHook and SWRInfiniteKeyLoader from infinite, rename InfiniteFetcher to SWRInfiniteFetcher by @houkanshan in #1714
- feat: Ensure auto revalidations are executed after state updates by @shuding in #1720
- Add moduleNameMapper to jest by @shuding in #1724
- Improve test by @promer94 in #1725
- feat: Use the latest reference of fetcher by @shuding in #1727
- fix: Re-export InfiniteFetcher by @shuding in #1728
- feat: Add
populateCache
option tomutate
by @shuding in #1729 - Fix local state sharing example deps by @huozhi in #1737
- Merge states for concurrent requests by @shuding in #1741
- Skip error retrying when document is not active and improve tests by @shuding in #1742
New Contributors
- @thomaspaulmann made their first contribution in #1707
- @houkanshan made their first contribution in #1714
Full Changelog: 1.1.1...1.1.2