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 pol…


This content originally appeared on DEV Community and was authored by SeongKuk Han

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();
    };
  }, []);


This content originally appeared on DEV Community and was authored by SeongKuk Han


Print Share Comment Cite Upload Translate Updates
APA

SeongKuk Han | Sciencx (2022-02-15T08:45:09+00:00) React Apollo: useQuery pollInterval with cache-and-network doesn’t stop to make requests after unmounting a component. Retrieved from https://www.scien.cx/2022/02/15/react-apollo-usequery-pollinterval-with-cache-and-network-doesnt-stop-to-make-requests-after-unmounting-a-component/

MLA
" » React Apollo: useQuery pollInterval with cache-and-network doesn’t stop to make requests after unmounting a component." SeongKuk Han | Sciencx - Tuesday February 15, 2022, https://www.scien.cx/2022/02/15/react-apollo-usequery-pollinterval-with-cache-and-network-doesnt-stop-to-make-requests-after-unmounting-a-component/
HARVARD
SeongKuk Han | Sciencx Tuesday February 15, 2022 » React Apollo: useQuery pollInterval with cache-and-network doesn’t stop to make requests after unmounting a component., viewed ,<https://www.scien.cx/2022/02/15/react-apollo-usequery-pollinterval-with-cache-and-network-doesnt-stop-to-make-requests-after-unmounting-a-component/>
VANCOUVER
SeongKuk Han | Sciencx - » React Apollo: useQuery pollInterval with cache-and-network doesn’t stop to make requests after unmounting a component. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/02/15/react-apollo-usequery-pollinterval-with-cache-and-network-doesnt-stop-to-make-requests-after-unmounting-a-component/
CHICAGO
" » React Apollo: useQuery pollInterval with cache-and-network doesn’t stop to make requests after unmounting a component." SeongKuk Han | Sciencx - Accessed . https://www.scien.cx/2022/02/15/react-apollo-usequery-pollinterval-with-cache-and-network-doesnt-stop-to-make-requests-after-unmounting-a-component/
IEEE
" » React Apollo: useQuery pollInterval with cache-and-network doesn’t stop to make requests after unmounting a component." SeongKuk Han | Sciencx [Online]. Available: https://www.scien.cx/2022/02/15/react-apollo-usequery-pollinterval-with-cache-and-network-doesnt-stop-to-make-requests-after-unmounting-a-component/. [Accessed: ]
rf:citation
» React Apollo: useQuery pollInterval with cache-and-network doesn’t stop to make requests after unmounting a component | SeongKuk Han | Sciencx | https://www.scien.cx/2022/02/15/react-apollo-usequery-pollinterval-with-cache-and-network-doesnt-stop-to-make-requests-after-unmounting-a-component/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.