T
TanStack10mo ago
like-gold

Prevent errorComponent on non-critical loader failure

Hi. Not sure if my title is very clear, sorry English is not my first language. So, in my case, in a route loader, I fetch some data but there are not mandatory for the page. Instead of an errorComponent blocking all my page, I would prefer to show my page and handle the error in it for just this part. I did this :
{
loader: async ({ context: { queryClient }}) {
queryClient.ensureQueryData(myFilter.list()).catch(() => {});
}
{
loader: async ({ context: { queryClient }}) {
queryClient.ensureQueryData(myFilter.list()).catch(() => {});
}
So with the catch, no error thrown and I can display my route and handle the error there (with useQuery(...).error) It works I guess but I don't like the .catch(() => {}) part of course. Is there a better way ? Thank you !
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?