T3 trpc depdent query is failing ?
I have this code , my third question
getQuestion
useQuery
is failing not sure why, I read about from online but adding enabled
did not solve it, the error is TypeError: Cannot read properties of undefined (reading 'length')
, can anyone help me on this ?
2 Replies
without the full error message it's difficult to tell what's going on. you might be running into problems with dependent queries so the docs might be helpful: https://tanstack.com/query/latest/docs/framework/react/guides/dependent-queries
Dependent Queries | TanStack Query React Docs
useQuery dependent Query
Dependent (or serial) queries depend on previous ones to finish before they can execute. To achieve this, it's as easy as using the enabled option to tell a query when it is ready to run:
also renaming your hooks like
event
and poll
to useEvent
and usePoll
would make it clear that they are hooks and need to be treated as such