我想将查询传递给 getAnalysisListByPatientIdApi 所以我尝试将查询放入 useInfiniteQuery 数组的第一个参数中,例如useQuery
const { data: analyses } = useInfiniteQuery(
['getAnalysesByPatientIdApi', { patientId: selectedPatientId }],
getAnalysisListByPatientIdApi,
{
getFetchMore: (lastGroup, allGroups) => {
const morePagesExist = lastGroup?.data.result.contents.length === 9
if (!morePagesExist) return false
return allGroups.length + 1
},
},
)
export const getAnalysisListByPatientIdApi = (_: string, query?: AnalysisListPatientQuery) => {
// should get query from useInfiniteQuery
return api.post<PagingResponse<AnalysisListPatientResponse>>(`/analysis/list/patient`, {
page: query?.page || 1,
size: query?.size || 9,
patientId: query?.patientId || '',
})
}
我希望从 getAnalysisListByPatientIdApi 中的 useInfiniteQuery 获得 { patientId: selectedPatientId },但发生错误:Type '{ patientId: string; }' is not assignable to type 'string'
。
如何解决这个问题?有任何想法吗?