-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I cancel Interval polling? #236
Comments
You can use a state for the interval, and set it to 0 when you want to cancel: const [int, setInt] = useState(3000)
const { data } = useSWR('/api', fetcher, { refreshInterval: int })
return <button onClick={() => setInt(0)}>cancel</button> |
thks |
dont work |
@Gavinchen92 Can you give me more details? Here's a working example: https://codesandbox.io/s/exciting-zhukovsky-jxm18 |
Same problem here. In React devtools you see |
I use refreshInterval to implement the Interval polling. But I'd know how to cancel it when it's running
The text was updated successfully, but these errors were encountered: