Skip to content

Commit

Permalink
fix(android) Fix crash with navigation on fabric by proper removal of…
Browse files Browse the repository at this point in the history
… view
  • Loading branch information
MrRefactor committed Nov 16, 2024
1 parent 5ca9aec commit ea6823f
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,19 @@ object PagerViewViewManagerImpl {
fun removeViewAt(parent: NestedScrollableHost, index: Int) {
val pager = getViewPager(parent)
val adapter = pager.adapter as ViewPagerAdapter?

val child = adapter?.getChildAt(index)

if (child != null && child.parent != null) {
(child.parent as? ViewGroup)?.removeView(child)
}

adapter?.removeChildAt(index)

// Required so ViewPager actually animates the removed view right away (otherwise
// a white screen is shown until the next user interaction).
// https://github.com/facebook/react-native/issues/17968#issuecomment-697136929
refreshViewChildrenLayout(pager)
pager.post {
pager.invalidate()
pager.requestLayout()
}
}

fun needsCustomLayoutForChildren(): Boolean {
Expand Down

0 comments on commit ea6823f

Please sign in to comment.