TanStackT
TanStack12mo ago
11 replies
worthy-azure

isLoading/isFetching is always true and data never gets populated

This seems to happen when I move through different pages quickly that use different useQuery hooks. But the bug is inconsistent. Sometimes under the same circumstances it will load the data, other times it will not (maybe something to do with the caching?).

dependencies:
`"@tanstack/react-query": "^5.62.7",
    "react": "^18",
    "react-dom": "^18",


I can also work to add the code snippets, but honestly they are very vanilla. They're incredibly basic useQuery hooks that calls a server function using prisma to a PostGresSql database.

here is one of the hooks for example:

export function useAdminProjects(): {
  data: ProjectWithDetails[] | undefined
  isLoading: boolean
  error: Error | null
} {
  const session = useSession()

  const { data, isLoading, error } = useQuery({
    queryKey: ["adminProjects", session?.data?.user.id],
    queryFn: () => getAdminProjects(session?.data?.user.id as string),
  })

  return { data, isLoading, error }
}


Any help largely appreciated as we've got a major release coming up! Thank you!!

EDIT: I don't believe its related to the session, as I see the call to the backend get hit, and session.data.user.id is the proper value and the backend throws no error, nor the frontend.
Was this page helpful?