T
TanStack3y ago
quickest-silver

Query.data being a function

i'm using solid start and solid query v4, and with the following code:
const channels = createQuery({
queryKey: () => ["servers", params.serverId, "channels"],
queryFn: (c) => fetch(`${import.meta.env.VITE_API_URL}/${API_VERSION}/${c.queryKey.join('/')}`).then((r) => r.json()),
initialData: [],
suspense: true,
})
const channels = createQuery({
queryKey: () => ["servers", params.serverId, "channels"],
queryFn: (c) => fetch(`${import.meta.env.VITE_API_URL}/${API_VERSION}/${c.queryKey.join('/')}`).then((r) => r.json()),
initialData: [],
suspense: true,
})
for a very short time channels.data becomes a function, and even typescript doesn't know about that, so is it intended behaviour or is it a bug?
2 Replies
unwilling-turquoise
unwilling-turquoise3y ago
Could you show a minimal reproduction of the issue?
quickest-silver
quickest-silverOP3y ago
with this code and console.log(channels.data) it logs the following:
[Function (anonymous)] // (not an array)
[]
[Function (anonymous)] // (not an array)
[]

Did you find this page helpful?