T
TanStack4y ago
genetic-orange

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
fascinating-indigo4y ago
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-orange
genetic-orangeOP4y ago
Thx for quick answer.

Did you find this page helpful?