javascript - fetchPolicy option: "no-cache" does not work in useQuery - Stack Overflow

this my codeconst { loading, error, data } = useQuery(HeaderPage.query, {fetchPolicy: "no-cache&qu

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
Add a ment  | 

1 Answer 1

Reset to default 6

When 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744052185a4550276.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信