Skip to content

Handle deprecation of BackHandler.removeEventListener #4738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 4.0
Choose a base branch
from

Conversation

wkirby
Copy link

@wkirby wkirby commented May 14, 2025

Motivation

In RN 0.77, they deprecated BackHandler.removeEventListener. The Modal component on the 4.x branch is set up to call hideModal when it's mounted with visible={false}, and because showModal has never been called, there's no existing subscription. Because of this, we fall to the else case which calls BackHandler.removeEventListener. Pre RN 0.77, this wasn't a problem, but because the function no longer exists, it now throws an error.

This patch simply adds a null check before trying to call the BackHandler.removeEventListener, which causes the above situation to fail gracefully.

Related issue

Test plan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant