I have a useQuery hook that makes a request every 1 min and trying to cancel polling once the component is unmounted. the RTK query doesn t seem to have in-house
way to cancel polling . I know there is skip
that doesn t seem to work.
Here is my failed attempt:
export const MyComponent = () => {
const [cancelPolling, setCancelPolling] = useState(false);
useGetTestQuery(undfined, {pollingInterval: !cancelPolling})
useEffect(() => {
() =>{
setCancellPoling(true)
}
},[setCancellPoling])
}
Is there a better alternative to my useEffect
attempt above or perhaps a built-in way that I somehow didn t find it on the doc?