T
TanStack15mo ago
jolly-crimson

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 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"
const data = useSomething()
console.log(data)
//for some reason data.data === undefined
//and data.status === "loading"
why?
1 Reply
jolly-crimson
jolly-crimsonOP15mo ago
RQ 3.6.0 it happens from time to time. i need that data which returns from usequery. but sometimes its undefined

Did you find this page helpful?