Skip to content

fix(android): scope back callbacks to the view lifecycle - #462

Open
likevy wants to merge 1 commit into
callstack:mainfrom
likevy:fix/457/back-callback-lifecycle
Open

fix(android): scope back callbacks to the view lifecycle#462
likevy wants to merge 1 commit into
callstack:mainfrom
likevy:fix/457/back-callback-lifecycle

Conversation

@likevy

@likevy likevy commented Sep 11, 2026

Copy link
Copy Markdown

Summary

Fixes #457.

Android back callbacks survived RN fragment view destruction, retaining delegates and intercepting back presses after re-entry.

  • Bind callbacks to the fragment view lifecycle and use the supplied owner for delegate lifecycle observation.
  • Preserve the existing createView API, add a lifecycle-owner overload, and restore callback enablement after native fallback exceptions.

Test plan

  1. Build RN AAR and AndroidApp example locally and run i.e. on API 35 simulator
  2. Add temp/ mount/unmount button to repeat 10 RN fragment visits within the same Activity
  3. Verify actual fragment view creation/destruction and that the Activity remained after each unmount
  4. Verify back callbacks were enabled while RN was mounted and no enabled callbacks emained after each unmount

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.

[Android] ReactNativeFragment leaks OnBackPressedCallback, breaking back after re-entry

1 participant