Allow you to call the default implementation of onErrorRetry #2204
Unanswered
robin-alphasophia
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I would suggest allowing developers to call the default implementation of the onErrorRetry function.
Let me give you an example of why this is relevant:
In my next.js app, I try to fetch a user switch SWR in the top level _app.ts file. If there is an error 401 unauthorized, I know the user is not logged in - in that case, I do not need SWR to retry fetching the data but send the user to the login page. However, if the error is any other error, I want SWR to run the default exponential backoff.
Essentially, I suggest allowing something like this:
Currently, I have solved it by coping the exponential backoff implementation from the SWR source code into my own source code, but now I am shipping twice the exact same code to our app users.
Best regards
Beta Was this translation helpful? Give feedback.
All reactions