@@ -154,19 +154,12 @@ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompo
154154 if (_removeClippedSubviews) {
155155 [_reactSubviews removeObjectAtIndex: index];
156156 } else {
157- RCTAssert (
158- childComponentView.superview != nil ,
159- @" Attempt to unmount a view which is not mounted. (parent: %@ , child: %@ , index: %@ )" ,
160- self,
161- childComponentView,
162- @(index));
163157 RCTAssert (
164158 childComponentView.superview == self.currentContainerView ,
165- @" Attempt to unmount a view which is mounted inside a different view. (parent: %@ , child: %@ , index: %@ , existing parent : %@ )" ,
159+ @" Attempt to unmount a view which is mounted inside different view. (parent: %@ , child: %@ , index: %@ )" ,
166160 self,
167161 childComponentView,
168- @(index),
169- @([childComponentView.superview tag ]));
162+ @(index));
170163 RCTAssert (
171164 (self.currentContainerView .subviews .count > index) &&
172165 [self .currentContainerView.subviews objectAtIndex: index] == childComponentView,
@@ -181,30 +174,6 @@ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompo
181174 [childComponentView removeFromSuperview ];
182175}
183176
184- - (void )_updateRemoveClippedSubviewsState
185- {
186- if (_removeClippedSubviews) {
187- // Toggled ON: populate _reactSubviews from the current view hierarchy.
188- // Actual clipping will happen on the next scroll event.
189- RCTAssert (
190- _reactSubviews.count == 0 ,
191- @" _reactSubviews should be empty when toggling removeClippedSubviews on. (view: %@ , count: %@ )" ,
192- self,
193- @(_reactSubviews.count ));
194- if (self.currentContainerView .subviews .count > 0 ) {
195- _reactSubviews = [NSMutableArray arrayWithArray: self .currentContainerView.subviews];
196- }
197- } else {
198- // Toggled OFF: re-mount all children in the correct order, then clear the tracking array.
199- // addSubview: on an already-present child moves it to the front, so iterating in order
200- // produces the correct subview ordering.
201- for (UIView *view in _reactSubviews) {
202- [self .currentContainerView addSubview: view];
203- }
204- [_reactSubviews removeAllObjects ];
205- }
206- }
207-
208177- (void )updateClippedSubviewsWithClipRect : (CGRect)clipRect relativeToView : (UIView *)clipView
209178{
210179 if (!_removeClippedSubviews) {
@@ -270,7 +239,9 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
270239 if (!ReactNativeFeatureFlags::enableViewCulling ()) {
271240 if (oldViewProps.removeClippedSubviews != newViewProps.removeClippedSubviews ) {
272241 _removeClippedSubviews = newViewProps.removeClippedSubviews ;
273- [self _updateRemoveClippedSubviewsState ];
242+ if (_removeClippedSubviews && self.currentContainerView .subviews .count > 0 ) {
243+ _reactSubviews = [NSMutableArray arrayWithArray: self .currentContainerView.subviews];
244+ }
274245 }
275246 }
276247
0 commit comments