T
TanStack7mo ago
foreign-sapphire

How to Handle notFound() Globally Instead of Checking 404 in Each Loader?

Instead of checking for a 404 status and throwing the notFound() function in each loader separately, can I handle it in one place? For example, in the onError handler of React Query’s QueryCache or in an Axios response interceptor? I’m trying to implement this as shown in the screenshots, but I’m still encountering an error, as you can see in the screenshots.
No description
No description
No description
1 Reply
exotic-emerald
exotic-emerald7mo ago
ideally provide this a a complete minimal example by forking one of the existing examples on stackblitz are you sure the error is thrown inside the loader and not from the component?

Did you find this page helpful?