Skip to content

️ deps: Bump swr from 1.1.2 to 1.2.1

Yogi Bot requested to merge dependabot-npm_and_yarn-swr-1.2.1 into main

Bumps swr from 1.1.2 to 1.2.1.

Release notes

Sourced from swr's releases.

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

New Contributors

Full Changelog: https://github.com/vercel/swr/compare/1.2.0...1.2.1

1.2.0

Highlights of This Release

Optimistic Updates with Auto Error Rollback

There are now some new options in mutate:

mutate(patchUser(user), {
  optimisticData: user,
  populateCache: true,
  rollbackOnError: true,
  revalidate: true,
})

... (truncated)

Commits

Merge request reports