Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Fix usage of removed method AppState.removeEventListener #2385

Merged

Conversation

trcoffman
Copy link
Contributor

AppState.removeEventListener was removed in react-native 0.70, after being deprecated for over a year. Anybody using react-native 0.70 will experience an unhandled TypeError when trying to invoke removeEventListener.

Replace the usage of removeEventListener with the remove() method on the subscription returned by addEventListener.

Stop reassigning the resumeListener argument. It's a bad practice to reassign function arguments, and it is common to have an eslint rule to block this. Rename the argument to retryOnAppResume so that when we create resumeListener, there is no reassignment of a function argument.

AppState.removeEventListener was removed in react-native 0.70, after being
deprecated for over a year. Anybody using react-native 0.70 will experience an
unhandled TypeError when trying to invoke removeEventListener.

Replace the usage of removeEventListener with the `remove()` method on the
subscription returned by addEventListener.

Stop reassigning the resumeListener argument. It's a bad practice to reassign
function arguments, and it is common to have an eslint rule to block this.
Rename the argument to retryOnAppResume so that when we create resumeListener,
there is no reassignment of a function argument.
@trcoffman trcoffman force-pushed the fixRemoveEventListenerUndefined branch from 9c64771 to b2a8d45 Compare December 14, 2022 00:21
@thewulf7 thewulf7 merged commit 9f903a9 into microsoft:master Dec 15, 2022
cc-matthias-m pushed a commit to ClubConnect/react-native-code-push that referenced this pull request Dec 23, 2022
)

AppState.removeEventListener was removed in react-native 0.70, after being
deprecated for over a year. Anybody using react-native 0.70 will experience an
unhandled TypeError when trying to invoke removeEventListener.

Replace the usage of removeEventListener with the `remove()` method on the
subscription returned by addEventListener.

Stop reassigning the resumeListener argument. It's a bad practice to reassign
function arguments, and it is common to have an eslint rule to block this.
Rename the argument to retryOnAppResume so that when we create resumeListener,
there is no reassignment of a function argument.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants