Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 15, 2022 08:45 am GMT

React Apollo: useQuery pollInterval with cache-and-network doesn't stop to make requests after unmounting a component

I've made the issue here in apollo-client repository.

It works well with other fetchPolicy options but it doens't work correctly with cache-and-network.

Before resolving the issue, here is one of the alternatives.

alternative

Starting polling manually

const {    data: todosData,    error,    startPolling,    stopPolling,  } = useQuery(GET_TODOS, {    fetchPolicy: "cache-and-network",  });  useEffect(() => {    startPolling(1000); // poll interval    return () => {      stopPolling();    };  }, []);

Original Link: https://dev.to/lico/usequery-pollinterval-with-cache-and-network-doesnt-stop-to-make-requests-after-unmounting-a-component-4hp8

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To