kesha-antonov/react-native-action-cable

removeEventListener is deprecated

Closed this issue · 2 comments

Aryk commented

On the newer versions of React Native, the removeEventListener is deprecated.

https://reactnative.dev/docs/appstate#removeeventlistener

In connection_monitor:

AppState.removeEventListener("change", @visibilityDidChange)

I think it needs to be something like this (I've never done coffeescript before):

  start: =>
    unless @isRunning()
      @startedAt = now()
      delete @stoppedAt
      @startPolling()
      @eventListener = AppState.addEventListener("change", @visibilityDidChange)
      @log("ConnectionMonitor started. pollInterval = #{@getPollInterval()} ms")

  stop: =>
    if @isRunning()
      @stoppedAt = now()
      @stopPolling()
      if @eventListener
        @eventListener.remove()
      @log("ConnectionMonitor stopped")

Yeah, you're right, your guess is correct.

Published new version with the fix