Skip to content
Source
Sign inSign up
TanStack/query

useQuery Never Resolves Despite queryFn Executing Successfully in React 16.14.0 (TanStack Query v4.36.1) #8644

Send to my agent
ClosedsamLiOfficial(GitHub profile, opens in a new tab) opened this issue 1 comment

Describe the bug

I am using useQuery from TanStack Query (@tanstack/react-query v4.36.1) in a React 16.14.0 project, and I noticed that the queryFn executes successfully (I see the expected console log), but the useQuery hook never resolves or updates the React component.

Your minimal, reproducible example

N/A

Steps to reproduce

import { useQuery } from '@tanstack/react-query'

// Custom hook using useQuery
const useCustomQuery = useQuery<QueryResultType>({
    queryKey: ['custom-query-key'],
    queryFn: async () => {
        const data = await fetchDataFromAPI()
        console.log('async function data', data) // ✅ This logs successfully
        return data
    },
    staleTime: 10000,
    enabled: isQueryEnabled, // `isQueryEnabled` is a boolean
})

console.log('useCustomQuery', useCustomQuery) // ❌ This never logs

return useCustomQuery

Steps to Reproduce

  1. Use useQuery as shown above.
  2. Confirm that fetchDataFromAPI() works outside useQuery (it does return data).
  3. Observe that console.log inside queryFn runs, but useQuery never updates.
  4. The React component does not rerender with the query result.

Expected behavior

Expected behavior

  • queryFn should execute and return the resolved data.
  • useQuery should update and log useCustomQuery.
  • The React component should rerender with the fetched data.

Actual behavior

  • The queryFn executes successfully (I see console.log('async function data', data) in the console).
  • However, useQuery never resolves or updates, and console.log('useCustomQuery', useCustomQuery) never logs.
  • The component does not receive the fetched data.

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

  • React: 16.14.0
  • TanStack Query: 4.36.1
  • Browser: Firefox 134.0.2 (aarch64)
  • Node.js: 18.20.5

Tanstack Query adapter

None

TanStack Query version

4.36.1

TypeScript version

5.6.2

Additional context

  • This issue occurs even when removing staleTime or enabled settings.
  • fetchDataFromAPI() works outside useQuery, so the API function itself is not the issue.
  • The issue persists across component re-renders.
  • I suspect an issue in React Query’s cache handling or state updates.
  1. Thank you for filing this issue, but we need more information before looking into this.

    Specifically, a minimal, standalone, runnable reproduction is needed - preferably with codesandbox or stackblitz.

    We'll close this issue for now, but we'll certainly re-open it if there is a proper reproduction.

  2. TkDodo closed this

  3. TkDodo added labelsneeds-info

Sign in to join this conversation.