do not send onScroll event when ScrollView is reused (#43676)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43676

changelog: [internal]

calling super invalidates eventEmitter. EventEmitter should be invalidated before reseting contentOffset on `_scrollView. Otherwise, UIScrollView::setContentOffset is called and it calls delegate method: `scrollViewDidScroll`.

Reviewed By: javache

Differential Revision: D55375060

fbshipit-source-id: f697805eb1ca05d15cf498ff9e5e06e90eb7ac56
This commit is contained in:
Samuel Susla
2024-03-27 09:39:01 -07:00
committed by Facebook GitHub Bot
parent 59a43e6d5d
commit 575507dd61
@@ -418,6 +418,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol
- (void)prepareForRecycle
{
[super prepareForRecycle];
const auto &props = static_cast<const ScrollViewProps &>(*_props);
_scrollView.contentOffset = RCTCGPointFromPoint(props.contentOffset);
// We set the default behavior to "never" so that iOS
@@ -433,7 +434,6 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol
_contentView = nil;
_prevFirstVisibleFrame = CGRectZero;
_firstVisibleView = nil;
[super prepareForRecycle];
}
#pragma mark - UIScrollViewDelegate