vector
vector10mo ago

Issue with usequery hooks (rendered more hooks than previous error)

Reference the attached screenshot for the error and the code.
No description
2 Replies
erquhart
erquhart10mo ago
Hooks can't run conditionally - the same hooks have to run in the same order on every render or you'll get that kind of error. You'll want to pass skip instead of an args object to useQuery() to avoid running the query before you have a userId. Docs here: https://docs.convex.dev/client/react#skipping-queries
const tweetIds = useQuery(api.backend.getTimelineTweets, userId ? { userId } : 'skip')
const tweetIds = useQuery(api.backend.getTimelineTweets, userId ? { userId } : 'skip')
vector
vectorOP10mo ago
thank you!

Did you find this page helpful?