-
-
Notifications
You must be signed in to change notification settings - Fork 234
Open
Description
In TanStack query, it's better to invalidate only the failed query on error instead of all queries. The global error handler should be updated to retry just the specific query.
In other words, this:
export const queryClient = new QueryClient({
queryCache: new QueryCache({
onError: (error) => {
toast.error(error.message, {
action: {
label: "retry",
onClick: () => {
queryClient.invalidateQueries();
},
},
});
},
}),
});should become this:
export const queryClient = new QueryClient({
queryCache: new QueryCache({
onError: (error, query) => {
toast.error(error.message, {
action: {
label: "retry",
onClick: query.invalidate,
},
});
},
}),
});Metadata
Metadata
Assignees
Labels
No labels