Skip to content

cancelAnimationFrame isn't compatible with WEB versionΒ #55104

@retyui

Description

@retyui

Description

cancelAnimationFrame isn't compatible with Web API (Web tested in Chrome; RN on iOS)

// Web
cancelAnimationFrame(-1); // ok 
cancelAnimationFrame(null); // ok
cancelAnimationFrame(undefined) // ok

// React Native
cancelAnimationFrame(-1); // Crash: clearTimeout called with an invalid handle

cancelAnimationFrame(null); // no crash! but TS error: TS2769: No overload matches this call. Argument of type `null` is not assignable to parameter of type `number`

cancelAnimationFrame(undefined); // no crash! but TS error: TS2769: No overload matches this call. Argument of type `undefined` is not assignable to parameter of type `number`

Steps to reproduce

see above

React Native Version

0.83.0

Affected Platforms

Runtime - iOS

Output of npx @react-native-community/cli info

System:
  OS: macOS 15.7
  CPU: (11) arm64 Apple M3 Pro
  Memory: 2.91 GB / 36.00 GB
  Shell:
    version: 4.0.1
    path: /opt/homebrew/bin/fish
Binaries:
  Node:
    version: 20.19.4
    path: /usr/local/bin/node
  Yarn:
    version: 3.6.4
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.8.2
    path: /usr/local/bin/npm
  Watchman:
    version: 2025.09.01.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/davyd.narbutovich/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2025.2 AI-252.27397.103.2522.14617522
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.13
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /Users/davyd.narbutovich/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.0.0
    wanted: 20.0.0
  react:
    installed: 19.2.0
    wanted: 19.2.0
  react-native:
    installed: 0.83.1
    wanted: 0.83.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

no

MANDATORY Reproducer

https://github.com/retyui/rn83

Screenshots and Videos

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions