mirror of
https://github.com/status-im/react-native.git
synced 2025-02-28 17:10:50 +00:00
Fixed bug where layoutSubviews was called continuously for scrollview
Summary: RCTScrollView was calling `dockClosestSectionHeader` in `reactBridgeDidFinishTransaction`, which triggers a layout update. The reason for this was in case the `stickyHeaderIndexes` property was updated, which would require the headers to be adjusted. However, doing this in `reactBridgeDidFinishTransaction` had the affect of causing `layoutSubviews` to be called repeatedly every frame even if nothing had changed and the scrollview wasn't moving, which was especially expensive when combined with the `removeClippedSubviews` logic, that loops through every view to calculate if it needs to be clipped. This fix moves the `dockClosestSectionHeader` call into `didUpdateProps`, and checks that the stickyHeaderIndexes have actually changed before calling it. Reviewed By: javache Differential Revision: D3387607 fbshipit-source-id: c71e00c6fac48337a63d7fee7c7c23e016acf24e
This commit is contained in:
parent
a8d4fbb5b2
commit
329c716897
@ -894,9 +894,14 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidZoom, onScroll)
|
||||
lastIndex, subviewCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didSetProps:(NSArray<NSString *> *)changedProps
|
||||
{
|
||||
if ([changedProps containsObject:@"stickyHeaderIndices"]) {
|
||||
[_scrollView dockClosestSectionHeader];
|
||||
}
|
||||
}
|
||||
|
||||
// Note: setting several properties of UIScrollView has the effect of
|
||||
// resetting its contentOffset to {0, 0}. To prevent this, we generate
|
||||
|
Loading…
x
Reference in New Issue
Block a user