I'm using the useMutation hook to delete the entity and the useQuery hook to load the entities from the api as follows:
const { mutate: $delete } = useMutation(deleteDiscipline, {
onSuccess: () => {
queryClient.invalidateQueries('disciplines')
},
})
const { isLoading, data: disciplines } = useQuery(['disciplines', filter], getFilteredDisciplines)
I rely on the isLoading field to display the loading status bar.
It works when I trigger refetch by switching tabs or changing the filter (query depends on filter state).
But when I call queryClient.invalidateQueries the api call is made and data is updated, but the isLoading field stays true for the entire refetching time.
Awaiting for the invalidation didn't help either:
const { mutate: $delete } = useMutation(deleteDiscipline, {
onSuccess: async () => {
await queryClient.invalidateQueries('disciplines')
},
})
How can I detect the request occurs (including all the triggers like query invalidations and others that I haven't encounter yet)?