alan2207 / bulletproof-react

🛡️ ⚛️ A simple, scalable, and powerful architecture for building production ready React applications.
MIT License
28.76k stars 2.6k forks source link

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

Open galih56 opened 1 year ago

galih56 commented 1 year ago

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

Antonious-Awad commented 3 months ago

@galih56 did you happen to find a solution?