vercel / swr-site

The official website for SWR.
https://swr.vercel.app
Apache License 2.0
481 stars 351 forks source link

`shouldRetryOnError` function usage not updated in "API" and "Error Handling" #559

Open taesungh opened 8 months ago

taesungh commented 8 months ago

Following from vercel/swr#1574 and vercel/swr#1816, the shouldRetryOnError option can accept a function to conditionally determine if SWR should retry. The notes for Release 1.2.1 provide a basic usage example copied here.

useSWR(key, fetcher, {
  shouldRetryOnError: (error) => {
    // We skip retrying if the API is returning 404:
    if (error.status === 404) return false
    return true
  }
})

As such, it would be very helpful if the Error Retry section of Error Handling and the Options section of API could be updated with this new usage.

piotr-cz commented 3 months ago

Yeah, without docs update it's an undocumented feature