useQuery - isLoading state not triggered
I have a Vite + React application. I fetch the todo data based on the page URL
When I switch from the
Currently I fetch data as such:
How do I fix this issue?
id param (example /my-todos/1 , /my-todos/2 etc.)When I switch from the
/my-todos/1 to /my-todos/2, the isLoading state stays false and I still see the old todo list for a split second.Currently I fetch data as such:
const { data, isLoading, isError, error } = useQuery({
queryKey: ["todos"],
queryFn: () => getOneTodoList(id!),
});How do I fix this issue?