Incorrect type for `getNextPageParam` in react-query's `prefetchInfiniteQuery` #8868
Send to my agentTkDodo added labelstypes
TkDodo closed this
TkDodo added labelsworks as designed
Sign in to join this conversation.
TkDodo added labelstypes
TkDodo closed this
TkDodo added labelsworks as designed
Sign in to join this conversation.
found out what the problem is: you should only pass
getNextPageParamif you also provide thepages: numberoption that specifies how many pages should be prefetched. If you don’t provide that, only one page will be fetched, so you don’t needgetNextPageParam.The reason why it doesn’t type-error better is because we want
fetchInfiniteQueryandprefetchInfiniteQueryto be compatible withinfiniteQueryOptions. You get a better type error if you passpages, but notgetNextPageParam:https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgRQK4FMoE8DCAbYdAOxgBoUNsAxVIgYxmAiJ2ZnQA94BfOAMygQQcAOQABGAEMiAZyl0A1gHoo6SQwC0AR0pYRAWABQRvrQZMicAOboYVCBAAUCMJJsAFSVEkhuALgpMLBp6RmZWEk4YAB5VSQATZjwsOABtOShgIisAXXIiVBAAI0wAPgBKRCM4OFUYVChLPls6AAtHAANWmBgwGT8lJU4fMDx0ADo6ISUAEhc3dE9vXw7yo24jIyJ0AHdA7HxCEkdy8bBVZpg2gEkiPizgdjQg52q4HSCAaXQsANSRPgOEQ5OCSGRwKayMhvB6MSR4TweLw+AIABlIbw+1CIARsdgcGMMNTxADkoojFsiQAFHHgwTAKZUALylOAARjghJqgxqvL5-N5AD0APxvVw2fpwACs63KQA