You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I am a bit confused, if the fetcher throws an error, the error goes up to the useSWR hook, then it goes up from the where it was called until it reaches some error boundary or is uncaught.
What is the point of error returned from useSWR, if you can't reach it?
const { data, error } = useSWR("123", () =>
new Promise((resolve, reject) => { setTimeout(() => reject("Data"), 2500) }), {
suspense: true, onError(err, key, config) {
console.log(err,key)
// Can't catch but error goes through here, so it's only useful for logging?
},
})
if (error) return <>Found error</> // <-------------- should never run, error was thrown
if(isLoading) return <>Loading</>
return <>{JSON.stringify(data)}</>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello. I am a bit confused, if the fetcher throws an error, the error goes up to the useSWR hook, then it goes up from the where it was called until it reaches some error boundary or is uncaught.
What is the point of error returned from useSWR, if you can't reach it?
edit: NVM, #959
Beta Was this translation helpful? Give feedback.
All reactions