Skip to content

EventTarget: addEventListener() method compatibility #55246

@retyui

Description

@retyui

Description

Modern API of EventTarget::addEventListener(type, listener, options) has options

AppState.addEventListener('change', listener, { once: true }); // auto cleanup a listener after dispatching  1st event  

AppState.addEventListener('change', listener, { signal: AbortSignal.timeout(5000) }); // auto cleanup a listener after 5s

But all the next methods from React Native are "EventTarget like", without options support

  • AccessibilityInfo.addEventListener()
  • Dimensions.addEventListener()
  • AppState.addEventListener()
  • Linking.addEventListener()
  • BackHandler.addEventListener()

Steps to reproduce

  1. AppState.addEventListener('change', console.log, {once: true})
  2. Open app move to background and back to foreground

Expected: only 1 change event
Actual: 2 events

React Native Version

0.83.1

Affected Platforms

Runtime - Android, Runtime - iOS, Runtime - Web

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

info Fetching system and libraries information...
System:
  OS: macOS 15.7.3
  CPU: (11) arm64 Apple M3 Pro
  Memory: 103.56 MB / 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/i/.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/i/.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

...

MANDATORY Reproducer

https://github.com/retyui/RN83-EventTarget

Screenshots and Videos

No response

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