Highlights of This Release
Dynamic refreshInterval
You can now pass a function as refreshInterval
, to dynamically return the interval (in millisecond) til the next request, based on the current data:
useSWR('key', fetcher, {
refreshInterval: function (data: Data | undefined) {
if (!data) return 3000 // Initial request
return data.next_update
}
})
If return 0
, polling will be stopped.
What's Changed
- feat: refreshInterval as a function by @Andrewnt219 in #1690
- test: add refreshInterval function returns 0 by @Andrewnt219 in #1691
- fix: If
newData
is deeply to the latest state, broadcast the latest state by @icyJoseph in #1697 - fix: Return
undefined
data if key's falsy under suspense mode by @icyJoseph in #1698
New Contributors
- @Andrewnt219 made their first contribution in #1690
- @icyJoseph made their first contribution in #1697
Full Changelog: 1.1.0...1.1.1