Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/react/useQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { QueriesObserver } from '../core/queriesObserver'
import { useQueryClient } from './QueryClientProvider'
import { UseQueryOptions, UseQueryResult } from './types'

export function useQueries(queries: UseQueryOptions[]): UseQueryResult[] {
export function useQueries<TData = unknown, TError = unknown>(queries: UseQueryOptions[]): UseQueryResult<TData,TError>[] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid I don't think it's that easy. we've had an open PR here that didn't quite make it: #1527

and there is an open issue with lots of discussions here: #1675

one problem is that every query in useQueries can have it's own type. It's not only for fetching N times the same query, I can also do:

useQueries([
  { queryKey: 'foo', queryFn: fetchFoo },
  { queryKey: 'bar', queryFn: fetchBar },
] as const)

where the result type should be ideal a tuple: [UseQueryResult<Foo>, UseQueryResult<Bar>]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I was too hopeful that it would be easy.

Thanks for your time. closing the pr

const mountedRef = React.useRef(false)
const [, forceUpdate] = React.useState(0)

Expand Down