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

TypeError : expected 'double' but had 'boolean' RNBackgroundTimer.setTimeout #65

Open
matthieupinte opened this issue Oct 19, 2017 · 5 comments

Comments

@matthieupinte
Copy link

I got some issues with react-native: ^0.49.3...

Hope you can help ^^,
removed it temporary and using default React Native Timer...

screen shot 2017-10-19 at 5 03 08 pm

@ximxim
Copy link

ximxim commented Nov 10, 2017

I am getting almost the same error when I enable hot reloading and make a change.

After further testing, I can recreate this issue by setting a timeout with no second parameter. Any suggestions how to resolve this issue?

@maartenpetit
Copy link

maartenpetit commented Nov 12, 2017

This error occurs every time I enable remote debugging, both iOS and Android.
"react-native": "^0.50.3"
"react-native-background-timer": "^1.3.0"

The following error occurs in iOS:

simulator screen shot - iphone 6 - 2017-11-12 at 15 56 41

@levity
Copy link

levity commented Nov 16, 2017

You can work around this by setting the global methods in a slightly different way, e.g.:

setTimeout = (fn, ms = 0) => Timer.setTimeout(fn, ms)
setInterval = (fn, ms = 0) => Timer.setInterval(fn, ms)
clearTimeout = (fn, ms = 0) => Timer.clearTimeout(fn, ms)
clearInterval = (fn, ms = 0) => Timer.clearInterval(fn, ms)

@tuna1207
Copy link

@levity i set the global methods like your example but still get the error , do you have any idea ? 😓

@tuna1207
Copy link

tuna1207 commented Apr 18, 2018

Got it solved by checking ms value

setTimeout = (fn, ms = 0) => {
  const numberMs = Number(ms)
  if (isNaN(numberMs)) return BackgroundTimer.setTimeout(fn, 0)
  return BackgroundTimer.setTimeout(fn, numberMs)
}
setInterval = (fn, ms = 0) => {
  const numberMs = Number(ms)
  if (isNaN(numberMs)) return BackgroundTimer.setInterval(fn, 0)
  return BackgroundTimer.setInterval(fn, numberMs)
}
clearTimeout = (fn, ms = 0) => {
  const numberMs = Number(ms)
  if (isNaN(numberMs)) return BackgroundTimer.clearTimeout(fn, 0)
  return BackgroundTimer.clearTimeout(fn, numberMs)
}
clearInterval = (fn, ms = 0) => {
  const numberMs = Number(ms)
  if (isNaN(numberMs)) return BackgroundTimer.clearInterval(fn, 0)
  return BackgroundTimer.clearInterval(fn, numberMs)
}

incrementing added a commit to incrementing/react-native-ntp-sync that referenced this issue Dec 4, 2020
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

5 participants