From 5f14001e929426144d1eaa5e5e52fb23a4d4f296 Mon Sep 17 00:00:00 2001 From: Gabriel Cadden Date: Wed, 19 Nov 2025 11:33:47 -0800 Subject: [PATCH] Fix crash by implementing scrollViewDidScroll in RCTEnhancedScrollView (#54583) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/54583 Fix crash by implementing the missing `scrollViewDidScroll:` method in `RCTEnhancedScrollView`. ## Root Cause `RCTEnhancedScrollView` conforms to `UIScrollViewDelegate` and adds itself as a delegate to its delegate splitter, but only implements two delegate methods: - `scrollViewWillEndDragging:withVelocity:targetContentOffset:` - `scrollViewDidZoom:` It was missing `scrollViewDidScroll:`, which is the most commonly called delegate method. When the splitter has multiple delegates, it sets itself as the UIScrollView's delegate and forwards messages to all registered delegates. When `UIScrollView` calls `scrollViewDidScroll:` on the splitter, the splitter attempts to forward it to `RCTEnhancedScrollView`, which doesn't implement it → crash: "unrecognized selector sent to instance". ## Solution Implement an empty `scrollViewDidScroll:` method in `RCTEnhancedScrollView`. ## Changelog [iOS][Fixed] - Fix crash in RCTEnhancedScrollView when scrollViewDidScroll is called Reviewed By: cipolleschi, keoskate Differential Revision: D86813725 fbshipit-source-id: dd1410ed389a4ab904d1583e1f83bb6122725b60 --- .../ComponentViews/ScrollView/RCTEnhancedScrollView.mm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm index 57204298af4..1b02e8b2d39 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm @@ -156,6 +156,12 @@ #pragma mark - UIScrollViewDelegate +- (void)scrollViewDidScroll:(__unused UIScrollView *)scrollView +{ + // Empty implementation. This method exists to prevent crashes when the delegate splitter + // forwards scrollViewDidScroll: messages to RCTEnhancedScrollView. +} + - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset