Swr: Retry or reFetch

Created on 6 Apr 2020  路  4Comments  路  Source: vercel/swr

How would I do that?

Like having a reFetch button or something?

Most helpful comment

Every useSWR call gives you a mutate function along the data and error objects, you can use it to mutate the data of that call or calling it without arguments to trigger a revalidation, that means SWR will fetch the data again and update the component with the new one.

All 4 comments

Every useSWR call gives you a mutate function along the data and error objects, you can use it to mutate the data of that call or calling it without arguments to trigger a revalidation, that means SWR will fetch the data again and update the component with the new one.

Like for example a reFetch button when request fails. Does above solution work for this use case?

Actually SWR automatically retries after a Fetch error, but yes, that use cause could be solved using mutate

Thank you馃帀馃帄

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bcomnes picture bcomnes  路  3Comments

polc picture polc  路  3Comments

AjaxSolutions picture AjaxSolutions  路  5Comments

bywo picture bywo  路  4Comments

tiagocorreiaalmeida picture tiagocorreiaalmeida  路  3Comments