Replies: 2 comments 4 replies
-
Well you don't have to do anything then... Just don't handle the error as you said. |
Beta Was this translation helpful? Give feedback.
1 reply
-
It sounds weird to me to "ignore error", IMO every error should notify you. If you want to only show the error alert or notification for the first time, you should consider doing this (which is not in the scope of SWR): // global level
const errorOccurred = {}
// component
const { data, error } = useSWR(
key,
fetcher,
{
refreshInterval: 15000,
onError(err) {
if (errorOccurred[key]) return
errorOccurred[key] = true
window.alert(err)
}
},
) Hope that helps! |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I just what to handle the error when first to fetch data. If the fetching data is triggered by the refreshInterval. I don't want to do anything. How can I config the useSWR?
Beta Was this translation helpful? Give feedback.
All reactions