TanStackT
TanStack2y ago
2 replies
technical-ivory

useQuery returns "loading" while data is already fetched

hi
can anyone explain me
i have a query
const useSomething() {
  return useQuery({
    queryFn: () => fetchFunc()
  })
}

const fetchFunc = async () => {
  const data = await fetch(....)
  console.log(data)
  // i have data here
  return data
}

const data = useSomething()
  console.log(data)
  //for some reason data.data === undefined
  //and data.status === "loading"

why?
Was this page helpful?