query-key-factory
query-key-factory copied to clipboard
Property 'pageParam' does not exist on type '{ queryKey: QueryKey; signal: AbortSignal; meta: Record<string, unknown> | undefined;
Hi
I'm trying to use createQueryKeys with useInfiniteQuery
when use ctx.pageParam type error occurred
Error Message
Property 'pageParam' does not exist on type '{ queryKey: QueryKey; signal: AbortSignal; meta: Record<string, unknown> | undefined; }'.ts(2339)
my Code is here
mails: (params) => ({
queryKey: [params],
queryFn: (ctx) =>
getRequest({ ...params, page: ctx.pageParam }),
}),
is there any way to use createQueryKeys with useInfiniteQuery
Any updates?
Also experiencing this error. I believe the type definitions of QueryKeyFactory need to be updated to have signal be optional
I'm facing the same bug
This is causing issues with other config properties (mutationKey and queryKey) when using any typed or common meta. Has anyone made any progress on investigating?
I fixed the problem migrating to the latest version of RQ. the v5
@apenab could you show your RQ and query-key-factory versions please?
The same problem. I have latest versions @tanstack/[email protected] and @lukemorales/[email protected].
With typescript I can't use query keys factory without errors. Here is example:
const exampleQueries = createQueryKeys('example', {
list: ({ id, ...params }: ExampleParams) => ({
queryKey: [id, params],
queryFn: (ctx) =>
axios.get(`example/${id}/list`, {
params: {
...params,
page: ctx.pageParam,
}
}),
}),
});
const id = '123';
useInfiniteQuery({
queryKey: exampleQueries.list(id).queryKey,
queryFn: exampleQueries.list(id).queryFn, // TypeScript error: Type number is not assignable to type never
initialPageParam: 1,
getNextPageParam: ({ page }) => (page + 1),
});