Skip to content

Commit dd716e8

Browse files
rubennortefacebook-github-bot
authored andcommitted
Add flag to do granular state updates in scroll views in iOS
Differential Revision: D45916675 fbshipit-source-id: f6d0722db658c5d744a8b9fa8b17c5736603b9f6
1 parent f083eca commit dd716e8

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ - (BOOL)touchesShouldCancelInContentView:(__unused UIView *)view
437437

438438
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
439439
{
440-
if (!_isUserTriggeredScrolling) {
440+
if (!_isUserTriggeredScrolling || CoreFeatures::enableGranularScrollViewStateUpdatesIOS) {
441441
[self _updateStateWithContentOffset];
442442
}
443443

packages/react-native/React/Fabric/RCTSurfacePresenter.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ - (RCTScheduler *)_createScheduler
276276
CoreFeatures::disableTransactionCommit = true;
277277
}
278278

279+
if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:enable_granular_scroll_view_state_updates_ios")) {
280+
CoreFeatures::enableGranularScrollViewStateUpdatesIOS = true;
281+
}
282+
279283
auto componentRegistryFactory =
280284
[factory = wrapManagedObject(_mountingManager.componentViewRegistry.componentViewFactory)](
281285
EventDispatcher::Weak const &eventDispatcher, ContextContainer::Shared const &contextContainer) {

packages/react-native/ReactCommon/react/renderer/core/CoreFeatures.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ bool CoreFeatures::useNativeState = false;
1616
bool CoreFeatures::cacheLastTextMeasurement = false;
1717
bool CoreFeatures::cancelImageDownloadsOnRecycle = false;
1818
bool CoreFeatures::disableTransactionCommit = false;
19+
bool CoreFeatures::enableGranularScrollViewStateUpdatesIOS = false;
1920

2021
} // namespace facebook::react

packages/react-native/ReactCommon/react/renderer/core/CoreFeatures.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ class CoreFeatures {
4848
// [CATransaction end] This feature flag disables it to measure its impact in
4949
// production.
5050
static bool disableTransactionCommit;
51+
52+
// When enabled, RCTScrollViewComponentView will trigger ShadowTree state
53+
// updates for all changes in scroll position.
54+
static bool enableGranularScrollViewStateUpdatesIOS;
5155
};
5256

5357
} // namespace facebook::react

0 commit comments

Comments
 (0)