Skip to content

setTimeout execute immediately at 1e12; This causes useRaf not working. #779

Open

Description

@cnwangjie

What is the current behavior?

useRaf not working at the default. After some testing, I found setTimeout execute immediately at 1e12.

image

https://codesandbox.io/s/silly-shadow-0vq5c?fontsize=14&hidenavigation=1&theme=dark

What is the expected behavior?

A little about versions:

  • OS: macOS Mojave
  • Browser (vendor and version): Chrome 80.0.3968.0
  • React: any version
  • react-use: 13.8.0

Activity

  1. thoamsy commented on Nov 28, 2019

    @thoamsy

    Maybe the browsers just throttle down the 1e12 to 0 or something else. Like the below code, you can see 10, 20, 30.

    setTimeout(() => console.log(20), 1);
    setTimeout(() => console.log(30), 1e12)
    console.log(10)

    I think you can use it with useRaf(50) instead of useRaf()

  2. xobotyi commented on Nov 28, 2019

    @xobotyi
    Contributor

    Whole JS setTimeout and setInterval does not work with numbers greater than 1e12(actually 2147483647) , because they use 32bit integer inside. https://stackoverflow.com/questions/3468607/why-does-settimeout-break-for-large-millisecond-delay-values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions