admin 管理员组文章数量: 1086019
this my code
const { loading, error, data } = useQuery(HeaderPage.query, {
fetchPolicy: "no-cache"
});
when i use fetchPolicy: "no-cache". Repeated request does not go.
What is the reason why only once a request is made ?
this my code
const { loading, error, data } = useQuery(HeaderPage.query, {
fetchPolicy: "no-cache"
});
when i use fetchPolicy: "no-cache". Repeated request does not go.
What is the reason why only once a request is made ?
Share Improve this question edited Jan 30, 2020 at 16:17 Edgar asked Jan 30, 2020 at 16:04 EdgarEdgar 6,86811 gold badges38 silver badges74 bronze badges 2- what do you mean about Repeated request ? – abdelhedi hlel Commented Jan 30, 2020 at 16:28
- when the ponent is first built, the request is sent and the second time the request does not occur – Edgar Commented Jan 30, 2020 at 16:47
1 Answer
Reset to default 6When you use the useQuery
hook, the query you provide is fetched when the ponent mounts. Whether it's fetched from the server or the cache will depend on your cache policy (and whether there's anything in the cache). After the query is initially fetched, it will only be fetched again if either 1) the options passed to the hook change or 2) you call the refetch
function returned by the hook. The query will not be fired again just because the ponent rerenders -- this would result in excessive requests and an infinite render loop.
本文标签: javascriptfetchPolicy option quotnocachequot does not work in useQueryStack Overflow
版权声明:本文标题:javascript - fetchPolicy option: "no-cache" does not work in useQuery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744052186a2525220.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论