我將 graphqlrefetch作為道具傳遞給組件,但我不確定應該是什么型別?
const { data, loading, refetch } = useQuery(gqlquery, {
variables: { where: { id: id } },
});
<myinfo
loading={loading}
data={data}
refetch={refetch}
/>
export const myinfo= ({
refetch,
loading,
data,
}: myinfoProps) => {}
type myinfoProps= {
refetch?: any;
loading: boolean;
data: {}
};
我想any從 refetch?: any;應該存在的東西中洗掉而不是。
uj5u.com熱心網友回復:
從檔案中,型別refetch是:
type myinfoProps= {
refetch?: (options: { throwOnError: boolean, cancelRefetch: boolean }) => Promise<UseQueryResult>;
loading: boolean;
data: {}
};
在呼叫時,您必須檢查它是否已定義,因為它是一個可選屬性:
export const myinfo= ({
refetch,
loading,
data,
}: myinfoProps) => {
if(refetch){
refetch(/* parameters */);
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/382646.html
上一篇:輸入'{'x-access-token':任意;}|{'x-access-token'?:未定義;}'不可分配給型別'AxiosR
