Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
Don't use React hook in onError callback
Browse files Browse the repository at this point in the history
  • Loading branch information
floriandejonckheere committed Nov 22, 2023
1 parent d5b2b64 commit e352443
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ const queryClient = new QueryClient({
queryCache: new QueryCache({
// @ts-expect-error - axios error type is not compatible with react-query
onError: (error: AxiosError) => {
const [, setToken] = useLocalStorage('token', null)

if (error.response?.status === 401) {
setToken(null)
localStorage.removeItem('token')
window.location.href = '/signin'
}
}
})
Expand Down

0 comments on commit e352443

Please sign in to comment.