Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React-query + axios errors trigger app crash with react-error-boundary #115

Open
galih56 opened this issue Feb 12, 2023 · 0 comments
Open

Comments

@galih56
Copy link

galih56 commented Feb 12, 2023

What if i don't use "useErrorBoundaries" in defaultQueryOptions?
My app always crash on the first mount when calling useAuth. The query returns 401 on the first fetch and it throws an error and crash the app. I already have axios interceptors built as a component wrapper to catch the 401. That doesn't solve the problem either. So i turned off the "useErrorBoundaries" and problem solved. But i wonder what kind of disadvantage i get when i deactivate the useErrorBoundaries. As far as i know, ErrorBoundary component is supposed to handle rendering error. Do we need react-error-boundary to handle server state error? I could've just navigate the page to login page if the user is unauthenticated

Any another ideas to solve this issue?

image

authentication functions
https://github.com/galih56/manpro-v2/blob/dev/resources/js/lib/authentication.tsx

Axios interceptor wrapper
https://github.com/galih56/manpro-v2/blob/dev/resources/js/lib/axios.tsx

@galih56 galih56 changed the title What if i don't use "useErrorBoundaries" in defaultQueryOptions? How to handle axios + react-query errors? Feb 12, 2023
@galih56 galih56 changed the title How to handle axios + react-query errors? React-query + axios errors trigger app crash with react-error-boundary Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant