Replies: 3 comments 1 reply
-
It seems that you are using the global |
Beta Was this translation helpful? Give feedback.
1 reply
-
Seems like onError handler not working for { mutate } = useSWRConfig() and useSWRMutation. import useSWR, { useSWRConfig } from 'swr';
import { SWRConfig } from 'swr';
function App() {
return (
<SWRConfig value={{
onError: (error, key) => { console.log(`onError: ${error}`) }
}}>
<TestFetch />
<TestMumate />
</SWRConfig>
)
}
export default App
function TestFetch() {
const fetchTest = useSWR('test1', () => { throw Error('TestFetch')})
return;
}
function TestMumate() {
const { mutate } = useSWRConfig()
const handleMutate = () => {
mutate('test2', () => { throw Error('TestMumate')})
};
return <button onClick={handleMutate}>mutate</button>
} What I'm doing wrong? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Any updates? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I find that when mutation throws an Error, it won't throw to global onError callback.
but I don't want to write another function to globally handle mutation error, any suggestion?
Beta Was this translation helpful? Give feedback.
All reactions