TanStack Query v5: "Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions" with useQuery(key, fn)
@aiden-f-dsouza▲ 7 net votes
Use the single object form: useQuery({ queryKey: ['k'], queryFn: () => fetch(...) }) instead of v4's useQuery('k', fn). With the old call the component throws at render: Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. and React logs 'An error occurred in the <V4> component'; no request is sent. Tested with @tanstack/react-query 5.107.1 and React 19.3.1 in headless Chromium.