1.2.1
Highlights of This Release
shouldRetryOnError
accepts a function
Previously shouldRetryOnError
is either true or false. Now it accepts a function that conditionally determines if SWR should retry. Here's a simple example:
const fetcher = url => fetch(url).then(res => {
// Fetcher throws if the response code is not 2xx.
if (!res.ok) throw res
return res.json()
})
useSWR(key, fetcher, {
shouldRetryOnError: (error) => {
// We skip retrying if the API is returning 404:
if (error.status === 404) return false
return true
}
})
Thanks to @sairajchouhan for contributing!
What's Changed
shouldRetryOnError
accepts a function that can be used to conditionally stop retrying by @sairajchouhan in #1816- build(deps-dev): bump next from 12.0.8 to 12.0.9 by @dependabot in #1821
- fix: useSWRInfinite revalidates with revalidateOnMount by @koba04 in #1830
New Contributors
- @sairajchouhan made their first contribution in #1816
Full Changelog: 1.2.0...1.2.1