Skip to content
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

BackgroundTimer.clearInterval not working #334

Open
sankomil opened this issue Jun 4, 2021 · 1 comment
Open

BackgroundTimer.clearInterval not working #334

sankomil opened this issue Jun 4, 2021 · 1 comment

Comments

@sankomil
Copy link

sankomil commented Jun 4, 2021

Hi, I am making a simple implementation of the background timer, just trying to console log a statement every 3 seconds. While the phrase is logged, when I call clearInterval through a button, it has no effect on the interval and the log continues. My code looks as such:

export const TestFunction = () => {

 const timeRef = BackgroundTimer.setInterval(() => {
     console.log('tac');
   }, 3000);

 return (

   <Button title="Press" onPress={()=>BackgroundTimer.clearInterval(timeref)} />
 )
}

react-native info:

System:
    OS: Windows 10 10.0.19042
    CPU: (8) x64 Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
    Memory: 5.80 GB / 15.83 GB
  Binaries:
    Node: 14.11.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK:
      API Levels: 29, 30
      Build Tools: 28.0.3, 29.0.2, 30.0.3
      System Images: android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom
      Android NDK: Not Found
    Windows SDK: Not Found
  IDEs:
    Android Studio: Version  4.1.0.0 AI-201.8743.12.41.6953283
    Visual Studio: Not Found
  Languages:
    Java: javac 15
    Python: 3.8.7
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^17.0.1 => 17.0.2
    react-native: 0.63.4 => 0.63.4
    react-native-windows: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Please let me know if any further information is needed. Thanks.

@jsellam
Copy link

jsellam commented Jun 30, 2021

Hi, try this :
BackgroundTimer.clearInterval(timeref.current)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants