mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
18f7abae07
commit
c42183817d
@@ -498,16 +498,15 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
|
||||
visibleFrame.size.width *= scale;
|
||||
visibleFrame.size.height *= scale;
|
||||
|
||||
#ifndef NDEBUG
|
||||
NSMutableArray<UIView<RCTComponentViewProtocol> *> *expectedSubviews = [NSMutableArray new];
|
||||
#endif
|
||||
|
||||
NSInteger mountedIndex = 0;
|
||||
for (UIView *componentView in _childComponentViews) {
|
||||
BOOL shouldBeMounted = YES;
|
||||
BOOL isMounted = componentView.superview != nil;
|
||||
|
||||
// If a view is mounted, it must be mounted exactly at `mountedIndex` position.
|
||||
RCTAssert(
|
||||
!isMounted || [_containerView.subviews objectAtIndex:mountedIndex] == componentView,
|
||||
@"Attempt to unmount improperly mounted component view.");
|
||||
|
||||
// It's simpler and faster to not mess with views that are not `RCTViewComponentView` subclasses.
|
||||
if ([componentView isKindOfClass:[RCTViewComponentView class]]) {
|
||||
RCTViewComponentView *viewComponentView = (RCTViewComponentView *)componentView;
|
||||
@@ -529,7 +528,24 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
|
||||
if (shouldBeMounted) {
|
||||
mountedIndex++;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (shouldBeMounted) {
|
||||
[expectedSubviews addObject:componentView];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
RCTAssert(
|
||||
_containerView.subviews.count == expectedSubviews.count,
|
||||
@"-[RCTScrollViewComponentView _remountChildren]: Inconsistency detected.");
|
||||
for (NSInteger i = 0; i < expectedSubviews.count; i++) {
|
||||
RCTAssert(
|
||||
[_containerView.subviews objectAtIndex:i] == [expectedSubviews objectAtIndex:i],
|
||||
@"-[RCTScrollViewComponentView _remountChildren]: Inconsistency detected.");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#pragma mark - RCTScrollableProtocol
|
||||
|
||||
Reference in New Issue
Block a user