Type data correctly when using InfiniteQuery and select-Function.
I got an InfiniteQuery with a select Function that reduces my data and returns it.
It looks something like:
select: (data)=>data.pages.reduce((acc, page) => [...acc, ...page.rows], []);
If I pass my type as TData. I would expect that query.data is TData[].
Instead it is {pages: TData[], pageParams: unknown[]}
Is there a way to type this correctly ?2 Replies
fascinating-indigo•4y ago
There's an open issue: https://github.com/TanStack/query/issues/3065
GitHub
TypeScript: Selectors for inifinite query less expressive · Issue #...
Describe the bug Selectors in combination with useQuery look very good. Creating multiple hooks on top of the original useQuery hook, allowing you to get different parts of the data out the query r...
genetic-orangeOP•4y ago
Thx for quick answer.