Skip to content

Commit ea6823f

Browse files
committed
fix(android) Fix crash with navigation on fabric by proper removal of view
1 parent 5ca9aec commit ea6823f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

android/src/main/java/com/reactnativepagerview/PagerViewViewManagerImpl.kt

+11-4
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,19 @@ object PagerViewViewManagerImpl {
6969
fun removeViewAt(parent: NestedScrollableHost, index: Int) {
7070
val pager = getViewPager(parent)
7171
val adapter = pager.adapter as ViewPagerAdapter?
72+
73+
val child = adapter?.getChildAt(index)
74+
75+
if (child != null && child.parent != null) {
76+
(child.parent as? ViewGroup)?.removeView(child)
77+
}
78+
7279
adapter?.removeChildAt(index)
7380

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

8087
fun needsCustomLayoutForChildren(): Boolean {

0 commit comments

Comments
 (0)