English 中文(简体)
Canceling pollingInterval on unmount RTK query
原标题:

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?

问题回答

暂无回答




相关问题
2. 在原木后向Austh 屏幕进行不再活的原住民

我正致力于在反应本土的仪器方面进行认证,当时,在我的一个用户记录中,我拯救了原体,然后使用标语显示经认证和未经验证的屏幕。 当Ilogin时,便发现......

Is there way to and how deploy jquery on top of redux?

i m about asking for help with a Redux/React js, as the several(~10) Freelance Modern JS technicians gave up on this task. The script in question is from the WordPress commercial theme i ve purchased ...

Canceling pollingInterval on unmount RTK query

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 ...

Correct use of ReactToPrint?

The problem is that the button that is supposed to give the option to print is not working anymore. the error in the console says: To print a functional component ensure it is wrapped with `React....

热门标签