Skip to content

fix(android): resolve resize and dismiss when the native view is gone - #1026

Closed
SamuelBrucksch wants to merge 2 commits into
lodev09:mainfrom
SamuelBrucksch:fix/android-missing-view-ref-methods
Closed

SamuelBrucksch wants to merge 2 commits into
lodev09:mainfrom
SamuelBrucksch:fix/android-missing-view-ref-methods

Conversation

@SamuelBrucksch

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #921, which fixed this for handleBackPress.

On Android, TrueSheetView.onHostDestroy drops the view from the module's registry. When the activity is destroyed but the JS runtime keeps running (a foreground service, or the process staying alive in the background), the JS sheet is still mounted. Effects that call ref.resize(), ref.dismiss() or ref.dismissStack() then reach withTrueSheetView, which rejects:

Error: TrueSheetView with tag 202 not found

Apps typically fire these calls without awaiting them (void sheetRef.current?.resize(i)), so the rejection becomes an unhandled promise rejection. In our production app this is ~6.7k events from ~3.5k users, all on Android. Breadcrumbs always show MainActivity destroyed, followed 0.2–2 s later by the rejection.

Fix: resize, dismiss and dismissStack ignore VIEW_NOT_FOUND (Android) and SHEET_NOT_FOUND (iOS) and resolve. A sheet whose native view no longer exists has nothing left to resize or dismiss. Every other error still rejects. present() is unchanged: if the view is gone, the caller asked to show something that can't be shown, so it should still find out.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Test Plan

  • New unit tests: resize, dismiss and dismissStack resolve on both codes, and other native errors still reject. The two resolve tests fail on main and pass here.
  • jest.setup.js now mocks resizeByRef and dismissStackByRef as well.

Screenshots / Videos

N/A

Checklist

  • I tested on iOS
  • I tested on Android
  • I tested on Web
  • I updated the documentation (if needed)
  • I added a changelog entry (if needed)

🤖 Generated with Claude Code

@vercel

vercel Bot commented Nov 17, 2026

Copy link
Copy Markdown

@SamuelBrucksch is attempting to deploy a commit to the lodev09 Team on Vercel.

A member of the Team first needs to authorize it.

SamuelBrucksch added a commit to SamuelBrucksch/react-native-true-sheet that referenced this pull request Nov 17, 2026
SamuelBrucksch and others added 2 commits November 17, 2026 12:00
onHostDestroy drops the view from the module's registry, but when the
activity is destroyed while the JS runtime keeps running, the JS sheet
stays mounted. resize(), dismiss() and dismissStack() then reject with
VIEW_NOT_FOUND, which surfaces as an unhandled rejection when callers
don't await them. Ignore VIEW_NOT_FOUND / SHEET_NOT_FOUND in those three
methods; present() still rejects.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@SamuelBrucksch
SamuelBrucksch force-pushed the fix/android-missing-view-ref-methods branch from a314271 to baae4b2 Compare November 17, 2026 11:01
@SamuelBrucksch
SamuelBrucksch marked this pull request as draft November 17, 2026 11:03
@SamuelBrucksch

Copy link
Copy Markdown
Contributor Author

Still need to check something...

@SamuelBrucksch
SamuelBrucksch deleted the fix/android-missing-view-ref-methods branch November 17, 2026 15:10
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