Skip to content

Commit c421838

Browse files
sherginfacebook-github-bot
authored andcommitted
Fixed incorrect assert in RCTScrollViewComponentView
Summary: This diff removes an incorrect assert and replaces it with a debug-only verification phase that compares "what we want" with "what we get". Changelog: [Internal] Fabric-specific internal change. Reviewed By: PeteTheHeat Differential Revision: D23983123 fbshipit-source-id: 03a628b4f8baa1f5fe4b55354b7c943e38b5e537
1 parent 18f7aba commit c421838

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,16 +498,15 @@ - (void)_remountChildren
498498
visibleFrame.size.width *= scale;
499499
visibleFrame.size.height *= scale;
500500

501+
#ifndef NDEBUG
502+
NSMutableArray<UIView<RCTComponentViewProtocol> *> *expectedSubviews = [NSMutableArray new];
503+
#endif
504+
501505
NSInteger mountedIndex = 0;
502506
for (UIView *componentView in _childComponentViews) {
503507
BOOL shouldBeMounted = YES;
504508
BOOL isMounted = componentView.superview != nil;
505509

506-
// If a view is mounted, it must be mounted exactly at `mountedIndex` position.
507-
RCTAssert(
508-
!isMounted || [_containerView.subviews objectAtIndex:mountedIndex] == componentView,
509-
@"Attempt to unmount improperly mounted component view.");
510-
511510
// It's simpler and faster to not mess with views that are not `RCTViewComponentView` subclasses.
512511
if ([componentView isKindOfClass:[RCTViewComponentView class]]) {
513512
RCTViewComponentView *viewComponentView = (RCTViewComponentView *)componentView;
@@ -529,7 +528,24 @@ - (void)_remountChildren
529528
if (shouldBeMounted) {
530529
mountedIndex++;
531530
}
531+
532+
#ifndef NDEBUG
533+
if (shouldBeMounted) {
534+
[expectedSubviews addObject:componentView];
535+
}
536+
#endif
537+
}
538+
539+
#ifndef NDEBUG
540+
RCTAssert(
541+
_containerView.subviews.count == expectedSubviews.count,
542+
@"-[RCTScrollViewComponentView _remountChildren]: Inconsistency detected.");
543+
for (NSInteger i = 0; i < expectedSubviews.count; i++) {
544+
RCTAssert(
545+
[_containerView.subviews objectAtIndex:i] == [expectedSubviews objectAtIndex:i],
546+
@"-[RCTScrollViewComponentView _remountChildren]: Inconsistency detected.");
532547
}
548+
#endif
533549
}
534550

535551
#pragma mark - RCTScrollableProtocol

0 commit comments

Comments
 (0)