Skip to content

Commit e4ac0dd

Browse files
committed
Revert "Make removeClippedSubviews toggle-resilient (#56211)"
This reverts commit 6560d16.
1 parent 6560d16 commit e4ac0dd

2 files changed

Lines changed: 5 additions & 179 deletions

File tree

packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,12 @@ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompo
156156
if (_removeClippedSubviews) {
157157
[_reactSubviews removeObjectAtIndex:index];
158158
} else {
159-
RCTAssert(
160-
childComponentView.superview != nil,
161-
@"Attempt to unmount a view which is not mounted. (parent: %@, child: %@, index: %@)",
162-
self,
163-
childComponentView,
164-
@(index));
165159
RCTAssert(
166160
childComponentView.superview == self.currentContainerView,
167-
@"Attempt to unmount a view which is mounted inside a different view. (parent: %@, child: %@, index: %@, existing parent: %@)",
161+
@"Attempt to unmount a view which is mounted inside different view. (parent: %@, child: %@, index: %@)",
168162
self,
169163
childComponentView,
170-
@(index),
171-
@([childComponentView.superview tag]));
164+
@(index));
172165
RCTAssert(
173166
(self.currentContainerView.subviews.count > index) &&
174167
[self.currentContainerView.subviews objectAtIndex:index] == childComponentView,
@@ -183,30 +176,6 @@ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompo
183176
[childComponentView removeFromSuperview];
184177
}
185178

186-
- (void)_updateRemoveClippedSubviewsState
187-
{
188-
if (_removeClippedSubviews) {
189-
// Toggled ON: populate _reactSubviews from the current view hierarchy.
190-
// Actual clipping will happen on the next scroll event.
191-
RCTAssert(
192-
_reactSubviews.count == 0,
193-
@"_reactSubviews should be empty when toggling removeClippedSubviews on. (view: %@, count: %@)",
194-
self,
195-
@(_reactSubviews.count));
196-
if (self.currentContainerView.subviews.count > 0) {
197-
_reactSubviews = [NSMutableArray arrayWithArray:self.currentContainerView.subviews];
198-
}
199-
} else {
200-
// Toggled OFF: re-mount all children in the correct order, then clear the tracking array.
201-
// addSubview: on an already-present child moves it to the front, so iterating in order
202-
// produces the correct subview ordering.
203-
for (UIView *view in _reactSubviews) {
204-
[self.currentContainerView addSubview:view];
205-
}
206-
[_reactSubviews removeAllObjects];
207-
}
208-
}
209-
210179
- (void)updateClippedSubviewsWithClipRect:(CGRect)clipRect relativeToView:(UIView *)clipView
211180
{
212181
if (!_removeClippedSubviews) {
@@ -272,7 +241,9 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
272241
if (!ReactNativeFeatureFlags::enableViewCulling()) {
273242
if (oldViewProps.removeClippedSubviews != newViewProps.removeClippedSubviews) {
274243
_removeClippedSubviews = newViewProps.removeClippedSubviews;
275-
[self _updateRemoveClippedSubviewsState];
244+
if (_removeClippedSubviews && self.currentContainerView.subviews.count > 0) {
245+
_reactSubviews = [NSMutableArray arrayWithArray:self.currentContainerView.subviews];
246+
}
276247
}
277248
}
278249

packages/react-native/React/Tests/Mounting/RCTViewComponentViewTests.mm

Lines changed: 0 additions & 145 deletions
This file was deleted.

0 commit comments

Comments
 (0)