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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744052185a4550276.html
评论列表(0条)