File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
android/src/main/java/com/reactnativepagerview Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,14 @@ class PagerViewViewManager : ViewGroupManager<ViewPager2>() {
101
101
return
102
102
}
103
103
(parent.adapter as FragmentAdapter ? )?.addFragment(child, index)
104
+
105
+ if (parent.currentItem == index) {
106
+ // Solves https://github.com/callstack/react-native-pager-view/issues/219
107
+ // Required so ViewPager actually displays first dynamically added child
108
+ // (otherwise a white screen is shown until the next user interaction).
109
+ // https://github.com/facebook/react-native/issues/17968#issuecomment-697136929
110
+ refreshViewChildrenLayout(parent)
111
+ }
104
112
}
105
113
106
114
override fun getChildCount (parent : ViewPager2 ): Int {
Original file line number Diff line number Diff line change @@ -198,11 +198,11 @@ - (UIViewController *)findCachedControllerForView:(UIView *)view {
198
198
}
199
199
200
200
- (void )updateDataSource {
201
- if (!self.currentView ) {
201
+ if (!self.currentView && self. reactSubviews . count == 0 ) {
202
202
return ;
203
203
}
204
204
205
- NSInteger newIndex = [self .reactSubviews indexOfObject: self .currentView];
205
+ NSInteger newIndex = self. currentView ? [self .reactSubviews indexOfObject: self .currentView] : 0 ;
206
206
207
207
if (newIndex == NSNotFound ) {
208
208
// Current view was removed
You can’t perform that action at this time.
0 commit comments