When the component unmounts, then polling should stop. Call the API when the component mounts, and if the attempt is successful, then return the data. In a nutshell, React Query helps fetch and cache server-side data and share it across the components. If we convince ourselves to use React Query, then all these operations become even more simpler with a few lines of useQuery: it’s highly configurable with a lot of batteries included..