From 575507dd61298be2f3071e0fc01ed9715cbd7a66 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Wed, 27 Mar 2024 09:39:01 -0700 Subject: [PATCH] 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 --- .../ComponentViews/ScrollView/RCTScrollViewComponentView.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index 50389ed4ae65b5..3839c1c72faeed 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -418,6 +418,7 @@ - (void)_updateStateWithContentOffset - (void)prepareForRecycle { + [super prepareForRecycle]; const auto &props = static_cast(*_props); _scrollView.contentOffset = RCTCGPointFromPoint(props.contentOffset); // We set the default behavior to "never" so that iOS @@ -433,7 +434,6 @@ - (void)prepareForRecycle _contentView = nil; _prevFirstVisibleFrame = CGRectZero; _firstVisibleView = nil; - [super prepareForRecycle]; } #pragma mark - UIScrollViewDelegate