-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Labels
Description
Describe the bug
When passing a string as the first parameter of useQuery(), it doesn't get passed into the defaultQueryFn correctly.
To Reproduce
Steps to reproduce the behavior:
- Create a
defaultQueryFnfor yourQueryClient - Provider the
QueryClientusingQueryClientProvider. - Try and run a query with
useQuery('my-endpoint') - See incorrect params being passed to
defaultQueryFn
Expected behavior
The queryKey passed to the defaultQueryFn should be in the format [key, params], no matter if useQuery() has been passed an array, string or object as the first parameter.
const defaultQueryFn = async ({ queryKey }) => {
const [key, params = {}] = queryKey;
// should equal { key: 'my-endpoint', params: {} }
// actually equals { key: 'm', params: y} }
console.log({ key, params })
});
//
const query = useQuery('my-endpoint');dalborgo and duniul