【发布时间】:2021-09-08 11:55:02
【问题描述】:
我正在使用来自react-query 的useQuery 来获取我只希望查询在某些条件下运行的数据。我该如何使用它?
以下是我使用useQuery的代码
const query = useQuery<APIResponse, Error>(
[{query: creatGQL, variables: variables}],
async () => {
const result: APIResponse = await ucFetch(apiUrl, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
query: creatGQL,
variables: variables,
}),
});
return result;
} );
return query;
【问题讨论】:
-
解决方案:stackoverflow.com/a/69760795/16983617 它对我有用。
标签: reactjs typescript react-query