Replies: 1 comment 3 replies
-
Something like this should do what you're looking for on a query level export const useGetCurrentUser = () => {
const queryClient = useQueryClient();
return useQuery(
["current-user"],
async () => {
const res = await axiosClient.get(`/user`);
return res.data;
},
{
onError: () => {
queryClient.setQueryData(["current-user"], (old) => null);
},
}
);
}; |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How to manually change data to null when useQuery fails
Beta Was this translation helpful? Give feedback.
All reactions